我写了个最简单的ajax代码,如下:
function fun() {
// alert("fef");
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
//document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
alert(xmlhttp.responseText);
}
}
xmlhttp.open("GET", "Data.aspx", true);
xmlhttp.send();
}
fun();
当请求Data.aspx时xmlhttp.status=403,请问该怎么解决这个问题,谢谢大家了。
function fun() {
// alert("fef");
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
//document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
alert(xmlhttp.responseText);
}
}
xmlhttp.open("GET", "Data.aspx", true);
xmlhttp.send();
}
fun();
当请求Data.aspx时xmlhttp.status=403,请问该怎么解决这个问题,谢谢大家了。
{
var ret = null;
try
{
ret = new ActiveXObject('Msxml2.XMLHTTP');
}
catch(e)
{
try
{
ret = new ActiveXObject('Microsoft.XMLHTTP');
}
catch(ee)
{
ret = null;
}
}
if (!ret && typeof XMLHttpRequest != 'undefined')
ret = new XMLHttpRequest();
return ret;
}