博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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\":\"返回内容\"})";
                     }

 

posted on 2012-12-12 16:21    阅读(321)  评论(0编辑  收藏  举报