客户端js脚本:
$.ajax({
type: "GET",
url: "http://www.aaa.com/getContent?r=" + Math.random(),
dataType: "jsonp",
jsonp: "jsoncallback",
timeout: "3000",
success: function(data){
alert(data); //得到服务器端的返回值"abc"
}
})
=============================================
服务器端代码:
public string getContent() { string strResult = "abc"; string callback = Request.QueryString["jsoncallback"]; return callback + "('" + strResult+ "')"; }
原文链接:https://www.f2er.com/json/288654.html