Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
234 views
in Q2A Core by
edited by

i am facing issue where it return a server 500 error sometimes when i submit an answer. 

Error message : "Unexpected response from server - please try again or switch off Javascript."

Looks like something seems to be interfering or misaligning the response text. which then is resulting in the error.

The answer is going through the database. However it returns with an error. Subsequent page refresh is showing up the answer i submit earlier.

Tried the following and feel like giving up.

1. Chrome network capturing. all this says is server encountered an error. 

2. My apache and php logs are all enabled including display errors =on, changing log level and error is not captured in the logs anywhere to diagnose.

Are there anyways to find out whats happening ?

One thing i can think of is to locate where in the backend are we preparing the "lines" output to be sent to the browser. and then compare it with a working response and a failing resposne to find out differences. Does anyone know where are we generating this "lines" array in the backend. 

qa_ajax_post('click_c', params,
        function (lines) {

or are there anyother better ways ? All i want to see is the error and the reason why this is happening.

Other Info: Whenever this happens, the post is going through but not adding a record in eventlog table. All other attempts is successfully adding records in event log as well as adding an answer. 

UPDATE : Looks like the issue is around event logging. Tried commenting out event reporting line in post-create.php. This resulted in hiding the error. However, i need to find out the cause on why event logger isnt working in few scenarios and need to fix it as soon as possible. Anyways to find out what the error Mysql is returning at the database level or something?

Q2A version: 1.7.4

1 Answer

+1 vote
by
The "lines" part you are talking about is what jQuery passes to the function when the AJAX request is completed. It contains whatever the server responded with. AJAX requests in Q2A should return "QA_AJAX_RESPONSE" on the first line, then 0 or 1 on the second line (0=error, 1=no error), then some HTML on the next lines.

In Chrome Network tab when you click a request look at the "Response" tab, that will show you what's returned and should display errors in there if you have display_errors turned on. If you're getting a 500 error that will probably be blank, but there should be an error logged somewhere.

There are various places for errors on the server. Apache has an error log (usually /var/log/apache2/error.log), as does MySQL (usually in /var/log/mysql/). PHP errors are usually saved to Apache error log, and you might see MySQL errors here as Q2A uses the error_log() function for those I think.

Do you have extra plugins installed (besides the defaults)? Try removing those one by one and see if that fixes the problem.
by
Thanks Scott. I tried removing one by one and finally found the issue is with send notify function. The email function. I remember i used to get a small message somewhere in the page saying "send email error" or something similar. This is acceptable as i have not configured the email part yet.
However, recently this message seems to have been supressed and this is causing screen to go blank without any errors or frendly mesages. is there any option in Q2A to supress email sending messages that i might have done inadvertently  ?
by
When you say "tried removing one" do you mean a plugin?

I don't think there is anything in Q2A that will suppress messages, but if the problem is due to a plugin it may be that plugin is overriding the function, and broke something.
by
Thanks scott. Just realised the issue was due to my self reducing the php execution timeout to few seconds to figure out some performance issues earlier. Looks like this is causing it to  supress the errors.  Reverting the setting to original 30 seconds has solved the issue for me.
...