2

I use jQuery Ajax. My success function:

...
success: function(data, status, xhr) {
     alert(data);
     r = resultResponse(data);
}
...

How can I get the data from response body (with xhr or with any other way except for data variable, because data variable is undefined opposite to there is data at response body)?

kamaci
  • 72,915
  • 69
  • 228
  • 366

2 Answers2

0

I need to see your full ajax code for this, but i have a suspicion.

If you have set an expected return format on your ajax call, it will expect the response body to be in that format, and if the response format is broken, the data will return empty.

e.g. if your ajax expects a JSON reply, but there is a syntax error such as a loose char before or after the JSON string, the data will return empty, but no error will be shown.

Can you show us your full ajax + paste the response body?

Rodik
  • 4,054
  • 26
  • 49
  • My question is related to my other two questions: http://stackoverflow.com/questions/11772299/jquery-ajax-doesnt-work-at-internet-explorer and http://stackoverflow.com/questions/11765363/jquery-ajax-get-doesnt-pass-received-data-into-success-function-at-internet-exp If you give an idea it will be so so nice. – kamaci Aug 02 '12 at 09:57
  • answered over at the other question. – Rodik Aug 02 '12 at 10:04
0

xhr.responseText returns the data, I had a problem with my charset so that's why I couldn't achieve to do it.

kamaci
  • 72,915
  • 69
  • 228
  • 366