两种方式:
方式一:
<script src="http://localhost:5295/Example?callback=showMessage" type="text/javascript"></script>
回调函数:
function showMessage(result) {
//alert(result.name);
workShopName = result.workShopName;
PersonFlag = result.PersonFlag;
PersonNum = result.PersonNum;
setsession(workShopName, PersonFlag, PersonNum);
alert("workShopName" + workShopName + PersonFlag + PersonNum);
}
方式二:
$.ajax({
type: 'GET',
url: "http://localhost:5295/Example?callback=showMessage",
async: false,
dataType: "jsonp",
jsonp: "showMessage",//传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(一般默认为:callback)
success: function () { }
//timeout: 3000
});
回调函数:
function showMessage(result) {
//alert(result.name);
workShopName = result.workShopName;
PersonFlag = result.PersonFlag;
PersonNum = result.PersonNum;
setsession(workShopName, PersonFlag, PersonNum);
alert("workShopName" + workShopName + PersonFlag + PersonNum);
}