javascript - jQuery[number] was not called -
ok, have searched question , have found numerous answers on none have worked me. i'm getting jquery21006460414978209883_1395689439888 not called error. ajax call done right, status 200 , php url i'm trying call, have validated json , valid json according jsonlint. i'm using jsonp since crossdomain call. advise me debug this. here javascript code:
$.ajax({ crossdomain: true, cache: false, type: "get", url: "http://example.com/backend.php", data: "fdaf", //async: false, datatype: "jsonp", contenttype: 'application/json; charset=utf-8', success: function(msg){ alert("success"+ json.stringify(msg)); }, error:function (xhr, ajaxoptions, thrownerror){ alert('error function status : '+xhr.status); alert('error thrown is: '+thrownerror); }, jsonp: "callback", complete: function (requeststate) { alert("working"); } });
my backend.php code here:
<?php header('content-type: application/json'); $arr = array('a' => "1", 'b' => "2", 'c' => "3", 'd' => "4"); $tr = json_encode($arr); echo $_get['callback'].'['.$tr.']'; ?>
please advise doing wrong here. many thanks!
your issue this, output of php:
callbackfunction[[data]]
this not call javascript function. should have output:
callbackfunction([data])
with php:
echo $_get['callback'].'('.$tr.')';
because $tr
array return [data]
you should need jsonp
if cross-domain request. otherwise use / post.
Comments
Post a Comment