J.K.A.
J.K.A.

Reputation: 7404

JSONP not giving any response

Following is my code :

$.ajax({
              url: url,
              type: 'GET',
              dataType: 'jsonp',
              error: function(xhr, status, error) {
                       alert("xhr="+xhr+"  status="+status+"   Error="+error);
                     },
                     success: function(jsonp) { 
                       alert("success");
                     }
      });

Url contains php file located on external server where I did echo json_encode($array);

Response is shown in firebug net tab but alert showing the following error :

xhr=[object Object] status=parsererror Error=Error: jQuery17209610263814778152_1338375769339 was not called.alert is not showing success

Upvotes: 0

Views: 182

Answers (1)

Esailija
Esailija

Reputation: 140236

Try this:

echo $_GET["callback"] . "(" . json_encode( $array ) . ");";

Upvotes: 4

Related Questions