Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
  • Register
Welcome to the Q&A for Question2Answer.

If you have questions about the platform, click here to ask and please use English.

If you just want to try Q2A, please use the demo, which also grants admin access.

Jan 18: 1.5 release

Why does WordPress break Ajax updates?

0 votes
Though posting questions, answers and comments works fine when external users are set to WordPress, the Ajax routines will not work. This prevents voting, and the update buttons in Admin Statistics.

All these fail with 'Failed to connect to site' message. Chrome browser reports 'Refused to set unsafe header "Content-length"' and 'Refused to set unsafe header "Connection"'

I've reached the end of my very limited knowledge of Ajax. I can see how the Q2A php and js files are supposed to work, but I just can't bring it all together to find the correct fix.

Any pointers on how to debug this issue further would be appreciated.
related to an answer for: How can I integrate it with wordpress?
asked May 30, 2010 in Q2A Core by shrewdies

1 Answer

+2 votes
 
Best answer
The most likely explanation is that something is being output by the file you modified, and this is interfering with the Ajax response.

If that isn't easy to spot, please post a link to your site, and I'll check out exactly what content is coming back in the HTTP response.
answered May 30, 2010 by gidgreen
OK, one way to debug it would be to add lots of:

echo __LINE__."\n";

statements inside the file qa-ajax-vote.php, and in addition add an

alert(response);

line inside qa-votes.js, just after:

function(response) {

That way you'll get a message in the browser showing you which lines of qa-ajax-vote.php were successfully executed, and where it failed. If this is to do with the external user code I suspect it will be related to qa_get_logged_in_user(...)

Actually, at a guess, it will be because the relative path you use in your require(...) in qa-external-users.php is not working because the Ajax voting PHP file is in a different directory to index.php. Instead you can try an absolute path, or one based on the QA_BASE_DIR constant, which will be defined the same for all requests.
"Instead you can try an absolute path"

You are an absolute star!

Voting and database cleanup operations now work fine. I'll amend my previous answer to suit.