We have implemented webservice which generates xml response.
I am facing issue while invoking it through the jquery ajax.
If I put same file within the same container I am getting a proper response. This is because of the cross domain policy.
Please suggest me how to use cross domain policy in jquery ajax?
I am using tomcat as a webserver. All webservices are deployed on this server.
Below is the code.
function doajaxcall()
{
$.ajax({
url: "http://localhost:8080/mobile-services/rest/languages/",
type: "GET",
processdata: true,
dataType: "json",
contentType: "application/json;",
beforeSend: function () { },
headers :
{
"Content-Type" : "application/json",
"Accept" : "application/json",
"Access-Control-Allow-Origin":"http://192.168.0.1:8080/"
},
success: function (data)
{
alert('Data..'+data);
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{
try
{
alert(JSON.stringify(XMLHttpRequest) + "\n" + textStatus + "\n" + errorThrown);
}
catch (ex) { alert("Exception occured.. "); }
finally { }
}
});
}
If i run this code from the same container in header i am getting "Access-Control-Allow-Origin":"http://192.168.0.1:8080/" in header.
If i run it outside of the container i am getting
"Access-Control-Allow-Origin":null
Please suggest.