My PHP backend sends XML response to the client (ajax):
<response>
<code>0</code>
<message>OK</message>
</response>
in the javascript I'm trying to get CODE value in this way: var errorCode = $('code', xml).text();
and then depending on errorCode value I do processing.
It is working fine in all browsers I tested except IE7. Instead of CODE value - it is giving me the empty string. The problem is not in 0 value, because I tried to use 5 as a code for e开发者_JAVA技巧xample - the result was the same.
Any ideas, because I'm stuck with :((
Thanks.
after some time of investigation, I found that I was stupid enough to post a question here.
The problem was that I simply forgot to send proper headers in my ajax controller.
after I added
header("Content-Type: text/xml; charset=utf-8");
it seems to me to work fine in IE7.
I will test all the rest browsers, but as the other browsers were correctly processing even simply the text, then with proper XML - there should not be any problem.
Thank you guys for efforts to help me.
Have you tried .val() or .html()?
Also, I believe jQuery's .ajax() function can parse XML for you.
EDIT: Actually I assume you're already using something like that. Never mind.
精彩评论