首页 新闻 会员 周边

jquery1.4.3 ajax提交json

0
[已关闭问题] 关闭于 2010-11-02 22:50

问个问题jquery1.4.3中ajax提交json数据有,对返回的json数据有啥要求呀。已经都加双引号了还是不行呀"{\"message\":\"123\"}";

  还是解析不到呀

问题补充: 前台 $.ajax({ type: "GET", contentType: "application/json", url: "Form.aspx", dataType: "json", data: "userName=" + $("#txtName").val(), beforeSend: function (XMLHttpRequest) { $("#showResult").text("正在查询"); //Pause(this,100000); }, success: function (msg) { $("#showResult").html(msg.message); $("#showResult").css("color", "red"); }, complete: function (XMLHttpRequest, textStatus) { //隐藏正在查询图片 }, error: function () { //错误处理 } }); } 后台 返回一个“{\"message\":\"123\"}";想获取里面message的值123
Rudy.Luo的主页 Rudy.Luo | 初学一级 | 园豆:200
提问于:2010-10-31 23:05
< >
分享
所有回答(5)
0

你应该是以post 方式提交的吧,用request.Form来获取

get方式的才是request.QueryString

wgz | 园豆:1254 (小虾三级) | 2010-11-01 08:38
0

代码?

慧☆星 | 园豆:5640 (大侠五级) | 2010-11-01 09:23
0

利用 Newtonsoft.net.json20.dll 解析 json格式。

Liujx | 园豆:9 (初学一级) | 2010-11-01 11:37
0

       $("#btnHello").click(function(){
            $.ajax({
                type: "POST",
                contentType:"application/json",
                url:"WebService1.asmx/Hello",
                data:'{name:"KiMoGiGi"}',
                dataType:'json',
                success:function(result){                   
                    alert(result.d);
                }
            });
        });

一滴血 | 园豆:1602 (小虾三级) | 2010-11-01 14:20
0

前台ajax调用实例:

 $.ajax({
             type: "POST",
             url: "Form.aspx",
             data: "userName=" + $("#txtName").val(),
             dataType: "json",
             success: function(msg) {
                 if (msg != null) {
                     alert(msg[0].message);
                 }
             }
         });

后端输出实例:

Response.Write("[{\"message\":\"123\"}]");

这样alert出来的结果就是123了

psforever | 园豆:461 (菜鸟二级) | 2012-06-01 22:16
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册