Ajax跨域

//region 跨域
function GetPersonList()
{
$.ajax({
type: "get",
async: false,
url: "GetPerson",
dataType: "jsonp",
jsonp: "callback",
success: function (p) {
//var p = getObject(json); //这里要注意下,jsonp返回之后jQuery会直接转成js对象,不用再转了。
$("#div1").text("姓名:" + p.Name + "年龄:" + p.Age);
alert(p.Name);
},
error: function () {
alert('跨域失败!');
}

})
}
//endregion

posted @ 2016-12-13 14:23  爱上-睡觉  阅读(109)  评论(0编辑  收藏  举报