Can AJAX calls be made from a local HTML/JS file (e.g., file://home/a.html) to a remote server (e.g., ) using functions like jQuery.ajax()? If so, how can XSS be enabled for this purpose (e.g., in FF3)?
I suspect it may involve certain browser security settings, but I'm unable to pinpoint which ones.
Additionally, is there a solution that doesn't require any changes on the server-side (such as JSONP)?
Thank you.
Code snippet:
function foo(){
$.ajax({
type: "POST",
url: "http://localhost:8080/api",
data: "Hello world",
success: function (data, textStatus, XMLHttpRequest) {
alert(data);
alert("success!");
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("fail");
}
});
}
...
...
<button onclick="foo()">click me</button>
Although I receive a "success" message, the data returned is empty.