Ajax compatibility issues in different browsers are troublesome, and I have encountered this problem in recent projects. And used a strange way to solve it, and now come out to discuss the discussion:
The following is the front-end code:
<script type= "Text/javascript" >
var xmlHttp;
var as;
var state = 0;
function MouseOver ()
{
var id = "<%=cvE_Mail.ClientID%>";
Getajax ();
if (as = = 0)
{
Alert ("Your WebBrowser don't support our service,choose IE7 or FireFox and try again!");
}
Else
{
At the time of the return, the state-setting event is different.
if (as = = 1)
{
Xmlhttp.onreadystatechange = Myresponsehandler;
}
Else
{
Xmlhttp.onload = Myresponsehandler;
Xmlhttp.onerror = Myresponsehandler;
}
In this case, when the open is chosen for GET, it is strange that Firefox's processing end will not receive the passed parameters
Here you can see that the last parameter is also different, and if not, then the returned responsetext is probably empty.
if (as = = 1)
{
Xmlhttp.open ("POST", "Ajax.ashx", true);
}
Else
{
Xmlhttp.open ("POST", "Ajax.ashx", false);
}
Xmlhttp.send (document.getElementById (ID). value);
}
};
function Getajax ()
{
The first is to create a different time
try {
XmlHttp = new ActiveXObject ("Microsoft.XMLHTTP");
as = 1;
catch (e) {
try {
XmlHttp = new ActiveXObject ("Msxml2.xmlhttp");
as = 1;
catch (e) {
try {
XmlHttp = new XMLHttpRequest ();
as = 2;
catch (e) {
XmlHttp = null;
as = 0;
}
}
}
}
function Myresponsehandler ()
{
var id = "<%=Hidebutton.ClientID%>";
if (xmlhttp.readystate = 4)
{
document.getElementById (ID). value=xmlhttp.responsetext;
}
};
</script>