why when I run this code on local server, req.send(sData)
doesn't work?
It runs alert1
but doesn't run alert2
;
function initialize() {
var req;
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (oc) {
req = null;
}
}
if (!req && typeof XMLHttpRequest != "undefined") {
req = new XMLHttpRequest();
}
return req;
}
function getData(sUrl, sData) {
var req = initialize();
req.open("POST", sUrl, false);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
alert("1");
req.send(sData);
alert("2");
return req.responseText;
}
sUrl and sData
are the same as the original website sends.