asp.net中的jquery json [英] jquery json in asp.net

查看:80
本文介绍了asp.net中的jquery json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。



i希望通过jquery ajax从服务器中的数据库获取一些数据。我知道任何关于JSON但我不能在asp.net4中实现一个例子。



i在webservice.cs文件中保留一个检查点,但运行剂量不会停在该检查点上。



my jquery代码自爆。

hi.

i want to get some data from database in server by jquery ajax.i know any about JSON but i cant implement an example in asp.net4.

i hold a checkpoint in webservice.cs file but running dose not stop on that checkpoint.

my jquery code is in blew.

function personaljson() {
            $.ajax({
                url: "JsonWebService.asmx/personalNamejson",
                type: "POST",
                datatype: "json",
                contenttype: "application/json; chaset=utf-8",
                success: function (msg) {
                    alert('successful jquery');
                    $('#Fname').html(msg);
                },
                error: function () {
                    alert('error in ajaxing');
                }
            });
        }

<a id="nameOpen" önclick="javascript:personaljson()" class="editTitle">personal editting</a>





和webservice.cs中的代码已经破灭。





and code in webservice.cs is in blew.

public string personalNamejson() {
        JavaScriptSerializer jss = new JavaScriptSerializer();
        string s = "reza";
        return jss.Serialize(s);
    }

推荐答案

.ajax({
url:JsonWebService.asmx / personalNamejson,
类型:POST,
数据类型:json,
contenttype:application / json; chaset = utf-8,
成功:函数(msg){
alert('成功的jquery');
.ajax({ url: "JsonWebService.asmx/personalNamejson", type: "POST", datatype: "json", contenttype: "application/json; chaset=utf-8", success: function (msg) { alert('successful jquery');


('#Fname')。html(msg);
},
错误:function(){
alert('ajaxing'中的错误);
}
});
}

< a id = nameOpen önclick = javascript:personaljson() class < span class =code-keyword> = editTitle > 个人编辑< span class =code-keyword>< / a >
('#Fname').html(msg); }, error: function () { alert('error in ajaxing'); } }); } <a id="nameOpen" önclick="javascript:personaljson()" class="editTitle">personal editting</a>





和webservice.cs中的代码已经破灭。





and code in webservice.cs is in blew.

public string personalNamejson() {
        JavaScriptSerializer jss = new JavaScriptSerializer();
        string s = "reza";
        return jss.Serialize(s);
    }


你不能这样调试。



使用开发人员工具 FireBug FireFox 中找出发生了什么并逐行调试你的客户端代码。



You can''t debug like that.

Use Developer Tools like FireBug in FireFox to find out what is happening and debug line by line of your client side code.

If it comes to success function, 
   then it is called successfully, 
otherwise 
   it will come to error function and you can see the error there. Then correct your code accordingly, if there is any.





你可以直接把调试器放在你的jQuery代码中,如果你写调试器; 你要停止的地方,或者你也可以在FireBug上执行。



You can directly put debugger in your jQuery code, if you write debugger; where you want to stop or else you can do it on FireBug also.


这篇关于asp.net中的jquery json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆