tags:

views:

25

answers:

2

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 example - the result was the same.

Any ideas, because I'm stuck with :((

Thanks.

A: 

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.

GeReV
neither val(), nor html() are working, tried everything.how .ajax() is parsing the XML? it is sending the request to server and launches the postprocessing in case of succes and error, but it is not parsing, am I mistaking?
A workaround might be using simple DOM methods with the responseXML returned by the ajax call. Example: http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=382#start. But I can't think of other solutions without seeing your code.
GeReV
+1  A: 

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.