I have a service which returns JSON data: http://api.drag2droid.shamanland.com/captcha?base64
I'm trying to execute simple AJAX request:
$.ajax({
type: "get",
url: "http://api.drag2droid.shamanland.com/captcha?base64",
dataType: "json",
success: function(data) {
$("body").html(data);
},
error: function(jqXHR, textStatus, errorThrown) {
$("body").html("ajax failed: " + textStatus + ", " + jqXHR.status + " " + errorThrown);
}
});
Result is:
ajax failed: error, 0
But if I just paste this url into address-bar in my browser, I can see json response.
Does somebody knows about possible traps?
JSFiddle: http://jsfiddle.net/shomeser/n5TjL/
EDITED:
Actually, I already set up my server-side to allow all requests from any domain with any header, PHP-code:
if ($_SERVER["REQUEST_METHOD"] == "OPTIONS") {
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Max-Age: 86400");
header("Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS");
if (isset($_SERVER["HTTP_ACCESS_CONTROL_REQUEST_HEADERS"])) {
header("Access-Control-Allow-Headers: {$_SERVER["HTTP_ACCESS_CONTROL_REQUEST_HEADERS"]}");
}
exit(0);
}
EDITED:
In the Network-tab of Firebug plugin I can see that there is no content retrieved:
But direct GET-reqeust from a browser shows full content.