开发者

Ajax works on Firefox but not on Internet Explorer - Need to update an XML file - No error message received

Well below you will find the code. I am trying to update an xml file with some answers that I will receive from the user However IE is not updating the file.... Could you please assist me?

    function updateXML(newtext, newtext2)
     {
     var xmlhttp;
     开发者_开发百科     if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
         xmlhttp=new XMLHttpRequest();
    }
    else
   {// code for IE6, IE5


       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

    }

       xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
  {

       return xmlhttp.responseText;
   }
  }

  xmlhttp.open("GET","here goes the url to retrieve xml data",true);

  xmlhttp.send();

}

I got most of this code from w3schools.com

Thank you very much for your help :)


You should try using JQuery.ajax(). It will take care of the browser inconsistencies for you.

For example:

$.ajax({
  url: "test.html",
  context: document.body,
  success: function(){
    $(this).addClass("done");
  }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜