首页 > 代码库 > jquery Jsonp 跨域访问
jquery Jsonp 跨域访问
$(function () {
$.ajax({
url: ‘http://ihisuns.vicp.cc:8765/PcClient.aspx‘,
data: { "ModuleName": "MiXinDialogue", "MethodName": "GetMiXinDialogue", "Id": "1" },
dataType: "jsonp",
jsonp: "jsonpcallback",
success: function (data) {
//var $ul = $("<ul></ul>");
//$.each(data, function (i, v) {
// $("<li/>").text(v["id"] + " " + v["name"]).appendTo($ul)
//});
//$("#res").append($ul);
alert(data);
},
beforeSend: function () {
$(".search_loading").show();
},
complete: function () {
$(".search_loading").hide();
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest.readyState + "||" + XMLHttpRequest.status + "||" + textStatus + "||" + errorThrown);
}
});
});
/************************************以下不大大意呀*********************/
后台后去jsonpcallback 自动生成的值
//Response.ContentType = "text/html; charset=utf8";
//Response.Write(callbackMethodName + "({\"employees\": [{\"firstName\": \"Bill\",\"lastName\": \"Gates\"}]})");
//Response.End();