Connecting Tech Pros Worldwide Help | Site Map

Crossbrowser Ajax - PRB: .responseText

  #1  
Old August 27th, 2008, 03:55 PM
par7133
Guest
 
Posts: n/a
Hi,
Yea, XMLHttpRequest give out a crossbrowser problem managing the
status change of the connection.

Here the solution:

var xmlhttp;
xmlhttp=null;



xmlhttp=new XMLHttpRequest();



if (xmlhttp!=null)
{
if (document.all) {
//THE PROBLEM



xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET",url,false);
xmlhttp.send(null);



function state_Change()
{
if (xmlhttp.readyState==4)
{// 4 = "loaded"
if (xmlhttp.status==200)
{// 200 = "OK"
response = xmlhttp.responseText;
}
else
{
// Problem retrieving data
}
}
}



if (response!="") {
// JSON code to manage the response

}



} else {



xmlhttp.open("GET",url);
xmlhttp.send(null);
xmlhttp.onreadystatechange=function ()
{
if (xmlhttp.readyState==4)
{// 4 = "loaded"
if (xmlhttp.status==200)
{// 200 = "OK"
response = xmlhttp.responseText;

if (response!="") {
// JSON code to manage the response
}

}
else
{
// Problem retrieving data
}
}
}



}

}
else
{
// Problem with XMLHTTP
}


Hope this helps,

http://blog.daniele.bonini.name/inde...-responsetext/
  #2  
Old August 27th, 2008, 08:25 PM
Gregor Kofler
Guest
 
Posts: n/a

re: Crossbrowser Ajax - PRB: .responseText


par7133 meinte:
Quote:
Hi,
Yea, XMLHttpRequest give out a crossbrowser problem managing the
status change of the connection.
>
Here the solution:
["solution" aka crap snipped]
Quote:
Hope this helps,
Whom? Why? And: No.

Gregor


--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Closed Thread