views:

74

answers:

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');
                            }
}
+1  A: 

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
your english is almost flawless in this post. You only missed a dont instead of don't.
Adriano Varoli Piazza
+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