P
petermichaux
Hi,
I thought it is about time I tried writing some JavaScript with
XMLHttpRequest instead of just using the Yahoo! UI library. The simple
page below works in both Safari and Opera but I don't see the alert in
Firefox. Looking in Firefox's firebug plugin, I see that the request is
successfully sent and the correct response is received. Any ideas what
is wrong?
Thank you,
Peter
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Simple XMLHttpRequest</title>
<script type="text/javascript">
function makeRequest(method, url) {
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (request.readyState == 4) {
// alert happens in Safari and Opera
// alert doesn't happen in Firefox
alert('handling readyState 4')
}
};
request.open(method, url);
request.send(null);
};
</script>
</head>
<body>
<p id="one">
<a href="#" onclick="makeRequest('GET', '/front/update'); return
false;">
do it!
</a>
</p>
</body>
</html>
I thought it is about time I tried writing some JavaScript with
XMLHttpRequest instead of just using the Yahoo! UI library. The simple
page below works in both Safari and Opera but I don't see the alert in
Firefox. Looking in Firefox's firebug plugin, I see that the request is
successfully sent and the correct response is received. Any ideas what
is wrong?
Thank you,
Peter
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Simple XMLHttpRequest</title>
<script type="text/javascript">
function makeRequest(method, url) {
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (request.readyState == 4) {
// alert happens in Safari and Opera
// alert doesn't happen in Firefox
alert('handling readyState 4')
}
};
request.open(method, url);
request.send(null);
};
</script>
</head>
<body>
<p id="one">
<a href="#" onclick="makeRequest('GET', '/front/update'); return
false;">
do it!
</a>
</p>
</body>
</html>