Javascript代码
View Code
1 $.ajax({ 2 3 url: "fromcar.ashx?methodName=toCart&callback=?", 4 contentType: "application/json;charset=utf-8", 5 type: "get",dataType: "jsonp", jsonp: "callback", 6 success: function(result) { //回调函数,result,返回值" 7 result=result.msg; 8 9 10 }, 11 error:function(XMLHttpRequest, textStatus, errorThrown){ 12 alert("..."); 13 } 14 }); 15 16 } 17 });
C#代码
if (context.Request.Params["callback"] != null) { string callback = context.Request.Params["callback"]; strMange = callback + "({\"msg\":\"返回内容\"})"; }