I want to get data from a sever.
Ex. I have get data with result is:
<input type=“text” name=“pg” value=“hihihi”></a>
when you run it with IE
But, My code don’t run with firefox, chrome:
Help me ???
Thanks all!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Using XMLHttpRequest</title>
<script type="text/javascript" src="1.js"></script>
</head>
<script>
function getHTTPObject() {
var xhr = false;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
xhr = false;
}
}
}
return xhr;
}
function grabFile(file) {
var request = getHTTPObject();
if (request) {
request.onreadystatechange = function() {
displayResponse(request);
};
request.open("GET", file, true);
request.send(null);
}
}
function displayResponse(request) {
if (request.readyState == 4) {
if (request.status == 200 || request.status == 304) {
alert(request.responseText);
}
}
}
</script>
<body>
<p>
<a href="http://muangay123.com/3.htm" onclick="grabFile(this.href); return false;">
click
</a>
</p>
</body>
</html>