Friday, 9 August 2013

$.post not working in ie. Alternative way help please?

$.post not working in ie. Alternative way help please?

I used $.post to send and receive response in my web page. But it is not
working in Internet Explorer. I used other way of Ajax. I have to create
xmlhttprequest object.
My code is
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)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","demo_post2.asp",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("fname=Henry&lname=Ford");
This works fine with all browser except ie-10. I write code like below to
support ie-10.
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP.6.0");
}
It is not working with mozila, safari but working with ie-10. I have not
checked with ie-7. It is a conflict. Please provide me any help
please...........

No comments:

Post a Comment