Hello, I have an application that calls a REST web service to obtain a JSON object. The call is:
$.ajax({
type: "GET",
url: urlWebService + "/getList"
processData: false,
crossDomain: true,
dataType: "application/json",
accepts: "application/json",
beforeSend: function (req) {
req.setRequestHeader('Accept', 'application/json');
req.setRequestHeader("Content-Type", "application/json");
},
cache: false,
success: function (msg) {
response_json = msg;
callback(response_json);
},
error: function (response) {
alert("Error");
}
});
The problem is that this call is only working in Firefox. I have tested with last version of other browsers (IE, Chrome, Safari and Opera) and doesn't work because in call headers Accept: undefined, application/json is sent and that 'undefined' makes the service fail. With firefox the header is Accept: application/json and that works ok. That's why I did:
beforeSend: function (req) {
req.setRequestHeader('Accept', 'application/json');
req.setRequestHeader("Content-Type", "application/json");
},
but seams that only works on firefox. Any idea? I can't find the solution.