I'm trying to access a REST Web Service from a HTML/JavaScript application. I'm accessing both the web application and the Web Service via Apache HTTPD 2.2. The Web Service GET method does work (executes and returns data) when called directly in a browser. The Web Service never receives the request when the call is attempted from the web application.
The web service URL is
http://127.0.0.1/pbws/all/
The web page that is calling it is
http://127.0.0.1/~myusername/phonebook/
I don't believe my problem is the Same Origin Policy as explained on Wikipedia ( http://en.wikipedia.org/wiki/Same_origin_policy ) I'm using the same host, protocol and port for both the web application and the called Web Service.
The call that is failing is:
getAll = function (callback) {
$.ajax({
type: "GET",
url: "http://127.0.0.1/pbws/all/",
dataType: "json",
async: true,
success: function (data, textStatus, jqXHR) {
callback(data);
},
error: function (jqXHR, textStatus, errorThrown) {
console.dir(jqXHR);
alert('getAll error: ' + textStatus);
}
});
};
The success is never called, only error. With a break point set, jqXHR doesn't contain any helpful information that I can see, textStatus = "error" and errorThrown is blank. The Chrome Developer Tools/Network tab shows the status as "(failed)".
I've tested this with both Chrome 23 and Firefox 16 on Windows 7. Any ideas as to what the problem can be or how to debug this further?