简体   繁体   中英

Ajax request in Chrome extension

I am developing an extenion which makes an ajax request to a web server like this

var xhr = new XMLHttpRequest();
xhr.open(method, url, true);
xhr.setRequestHeader("Content-Type","application/json");
xhr.send(JSON.stringify(data));
xhr.onreadystatechange = function() 
{ 
    if(xhr.readyState == 4 && xhr.status == 204) 
    { 
            //debugger;
            alert("Logged in");
            flag = 1;
            _callBack(xhr, xhr.readyState);
    }
}

And here i am able to logged in with status = 204 and now once i logged in i am trying to go for different directory for example www.example.com/index/enter with another ajax request in same extension but could not able to do so.

Are you sure you're expecting the same HTTP response code? It's very likely that the server you're making requests to is sending a different response for a different request URL.

204 No Reponse = there is no response data

200 OK = there is data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM