getJSON, URL, PHP responses?
I am not quite certain I am doing this correctly however from everything I have read/researched from the jquery howto's, forums and example pages my code should work correctly.
First I am attempting to load a json response generated from a php file on another server using the jquery.getJSON function.
- <script>
$("#permissions").click(function() {
$.getJSON({
dataType: 'json',
url: "http://server/file.php?callback=?",
data: ({ token: "12345", resource: "abcde" }),
success: function(XMLHttpRequest,textStatus, errorThrown) {
alert(textStatus);
alert(errorThrown);
alert(XMLHttpRequest.responseText);
},
error: function(XMLHttpRequest,textStatus, errorThrown) {
alert(textStatus);
alert(errorThrown);
alert(XMLHttpRequest.responseText);
}
});
});
</script>
No errors in syntax so far, so good right?
The contents of 'http://server/file.php?callback=?' are as follows:
- $arrGetDataResponse = array( "resource" => 0, "uid" => 0, "gid" => 0 );
- if( function_exists( "json_encode" ) ) {
$jsonGetData = json_encode( $arrPostDataResponse );
}
return $jsonGetData;
Also fairly easy right? the page simply returns an array of data as a json object.
I cannot get the getJSON function to actually query the server and recieve 404 errors in the raw header output.
Am I doing something wrong? Could SSL be a problem?