jq ajax jsonp 对接php写法

$.ajax({

type: "GET",

url: "http://love.com/Test.php",

dataType: "jsonp",

// jsonp:"somfun",

success:function(msg){

console.log(msg.msg);

},

error:function (error) {

console.log(111);

console.log(error);

}

});

http://love.com/Test.php

$data['msg']=1;
//echo $_GET['somfun'].'('.json_encode($data).')';
echo $_GET['callback'].'('.json_encode($data).')';

猜你喜欢

转载自blog.csdn.net/qq_37779709/article/details/84072281