XML parsing of server response...

XML parsing of server response...

Hi,

I try to read data from an XML file called by ajax:

  1. function sendFrm(){
  2. $.ajax({  
  3.             type: "POST",  
  4.             url: "jqueryServer.asp",  
  5.             data: "firstName="+ obj('firstName'),  
  6.     dataType: "xml",
  7.             success: readXML
  8.   });
  9. }

Ithe server send me this XML:

  1. <?xml version='1.0' encoding='ISO-8859-1'?>
  2. <root>
  3.       <vars>
  4.             <firstName>MyName</firstName>
  5.       </vars>
  6. </root>

So I read the XML in this way:

  1. function readXML(xml){
  2. $(xml).find('vars').each(function(){
  3.                          var f = $(this).find('firstName').text();
  4.                          alert(f);
  5.                         }); }

Why the alert shows as response "objectHTMLInputElement" instead of " MyName " ?

Thanks
    • Topic Participants

    • fabio