Thursday, 8 August 2013

Ajax not calling callback function

Ajax not calling callback function

I am trying to get a JSON object from a service running on port 8080 on my
server. I have implemented the following JavaScript and PHP code to
achieve this:
JavaScript:
$.ajax({
type: 'GET',
url: "mediainfo.php?file="+stream_,
dataType: 'json',
success: play,
error: function(xhr, reply) {
play({});
}});
mediainfo.php:
<?php
$url = "http://localhost:8080/media_info/" . $_GET['file'];
echo file_get_contents($url);
However even if the Ajax call succeeds it never calls the callback.
Strangely if it fails (e.g. if $url does not return valid JSON) it does
call the callback.
I can't figure out what's going wrong. Any help would be much appreciated.

No comments:

Post a Comment