0

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.

Arjit
  • 3,290
  • 1
  • 17
  • 18
SalmanShariati
  • 3,873
  • 4
  • 27
  • 46
  • what is your sdata value? – Arjit Mar 29 '14 at 11:02
  • sData = data=d_autogen1[]d_autogen1[]d_autogen2[]d_autogen2[]From[MHD]To[ABD]Date[2014___S_L_A_S_H___03___S_L_A_S_H___31]Counter[1]TypeSort[Price]&pageaction=getdata&SystemID=2aad5e28-3dd2-4674-8078-a40a143eaf88&LanguageID=b3642705-78ba-4f5a-be67-e18ad8837255&Stats=Search – SalmanShariati Mar 29 '14 at 11:09
  • I should say that there is a website with this codes and it shows results of flight informations. I want to send a custom request to it's ajax url and get results. – SalmanShariati Mar 29 '14 at 11:10

0 Answers0