469,331 Members | 4,501 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,331 developers. It's quick & easy.

Crossbrowser Ajax - PRB: .responseText

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/
Aug 27 '08 #1
1 1571
par7133 meinte:
Hi,
Yea, XMLHttpRequest give out a crossbrowser problem managing the
status change of the connection.

Here the solution:
["solution" aka crap snipped]
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
Aug 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.