1

Hallo all , i have wirtten an ajax request to the database server and the return datatype is xml but the IE is unable to render it. but on chrome it works.what could possibly be wrong in my codeActually i get no response for the the server.the element name i am using in my xml doc is ,,, and notthing more. so i really donotttt know where the problem can lie.

  $.ajax({
         url:'gethint.php',
         type:'GET',
         data:'p=p' + '&cust_uid=i',
         datatype:'xml',
         timeout:5000,
         error:function(){alert('unable to establish connection to the server ');},
         success:function(xml){outputResponseXML(xml);}
    });
    function outputResponseXML(xml)
{
   $('div#me').empty();
     var element =$(xml).find('USER');
         if(element.length>0)
            {

             $(xml).find('USER').each(
             function(index)
              {

                  var ename= ($(this).find('ENAME').text()=='E')?'':$(this).find('ENAME').text();
                  var operator=($(this).find('OPERATOR').text()=='E')?'':$(this).find('OPERATOR').text();
                  var pnr =($(this).find('PNR').text()=='E')?'':$(this).find('PNR').text();
                  var inr=($(this).find('INR').text()=='E')?'':$(this).find('INR').text();
                  var $newDiv= $( '<div class=\"items\" id =\"'+inr +'\">'
                                 +ename+'<br/>'+operator+
                                '<br/>'+ pnr+'</div>');   
                                   $newDiv.appendTo('div#me');
                                  });

                            }
                            else
                            {
                                $('div.me').html('no suggestions found');
                            }
}
apaderno
  • 28,547
  • 16
  • 75
  • 90
fon
  • 255
  • 2
  • 7
  • 16
  • Can you post the response coming back? IE doesn't like element names that are actual HTML elements in your XML. – Nick Craver Jun 25 '10 at 12:03
  • I see that you had a similar question the other day. http://stackoverflow.com/questions/3081071/convert-a-string-to-xml-doc-with-jquery-or-the-other-way-round Did **Aaron's** answer help at all? It should work. Are "Add-ons" disabled in the IE you're using? It apparently happens in some installations. – user113716 Jun 25 '10 at 12:44
  • well i am not realy versed with the IE , so but i was thinking that it can be that the jquery in IE does not recognise the XML doc return form the request. i donot know if there is another work arround for that – fon Jun 25 '10 at 13:17
  • You need to use the solution in your other answer to make the XML such that IE can parse it. If your browser doesn't have Add-ons enabled, it won't work. The icon you click to open IE may read `Internet Explorer [no add-ons]` or something similar. – user113716 Jun 25 '10 at 13:42
  • If you can load the response in internet explorer without using jquery (change what is providing the response to accept GET, pass parameters, and check response) then you will have a better idea of what the issue is. – Mervyn Jun 25 '10 at 13:45

1 Answers1

1

I think the problem is with your "gethint.php" page.

Try to set the header of your PHP page to:

header("Content-Type: text/xml; charset=utf-8", true);
header("Cache-Control: no-cache, must-revalidate"); 
header("Expires: -1"); 
header("Pragma: no-cache");

And dont forget to print this line in your XML result (must be the first line)

<?xml version="1.0" encoding="utf-8"?>

This guarantee that Internet Explorer will read it correctly.

Clean your cache after the changes.

I'm glad if it helped. Sorry for the bad english. It's not my primary language.

Philipe
  • 572
  • 3
  • 14
  • your english is almost flawless in this post. You only missed a dont instead of don't. – Adriano Varoli Piazza Jun 25 '10 at 16:15
  • 1
    +1. The Content-Type is key. If the script can't tell it's XML, it won't even bother parsing it. responseText will have the correct data, but responseXML will be `null`. If the site traffic is high and this file is loaded a lot, disabling browser-side caching can have extremely negative effects. – Andrew Jun 25 '10 at 16:18