+ -
当前位置:首页 → 问答吧 → jquery+json

jquery+json

时间:2011-05-11

来源:互联网

JScript code
        $("#btnHelloWorld").click(function(){
            $.ajax({
                type: "POST",
                contentType:"application/json",
                url:"WebService1.asmx/HelloWorld",
                data:"{}",
                dataType:'json',
                success:function(result){                    
                    alert(result.d);
                }
            });
        }); 

作者: chenbin6562   发布时间: 2011-05-11

问题是:里面这个result.d
后面这个.d究竟是什么作用?!一直没搞明白,谢谢!

作者: chenbin6562   发布时间: 2011-05-11

如果返回结果是json格式的话,类似{d:"123"}

alert(result.d);就有结果了

作者: hongmei85   发布时间: 2011-05-11

请问有什么工具可以抓到web service返回的内容吗?!
象这个代码,对应的WEB SERVICE方法就只是返回了一个"hello world"的字符串,怎么会被格式化为{d:"hello world"}了

作者: chenbin6562   发布时间: 2011-05-11

.net3.5增加了检查contenttype,如果设置contenttype未contentType:"application/json",就会返回那种格式的字符串

firebug查看xhr请求返回的内容即可

作者: showbo   发布时间: 2011-05-11

热门下载

更多