XMLHTTPRequest Not returning

1.9k views Asked by At

I created a java script to connect to my web service however I never return from the send method of my request:

    var request = new XMLHttpRequest();
    request.overrideMimeType('text/plain');
    request.open("GET", url, false);
    request.send(null);

    alert("Complete");

I never see the alert. However when I step through my service it returns successfully so it has to be with this script.

Note: I can run the url from a browser, chorme or firefox tested, and I am able to get the response I want. I just cannot get it from js.

2

There are 2 answers

0
cain4355 On BEST ANSWER

My web service was not set up to receive HTTP GET request (REST based service). I was only set up to handle SOAP based requests.

3
Yo All On

Perhaps it is because of the false in request.open(), which means that the request is synchronous, so the rest of the script won't continue executing until the response has arrived from the server. Does the server return the response package? If it doesn't, you should try changing the third argument of the function to true, it should continue with the script execution then.

Check this link out: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#send()