English 中文(简体)
处理数据,采用网络方法,作为“智者”和“ j”。
原标题:Dealing with Data Returned by a Web Method as JSON with jQuery

我与JSON有更大的问题!

我正在利用本条提供的咨询意见:http://encosia.com/using-jquery-to-directly-quest-aspnet-ajax-page-methods/“rel=“nofollow” http://ensiaco.com/using-jquery-to-directly----bet-aspnet-ajax-page-methods/

我利用这一方法,设法利用服务器边网络方法与日本宇宙航空研究开发机构开展行动。

在大多数情况下,我只需要做 st(例如,只需要一个数据库),所以不需要做任何反应,但现在,我已经走过了我做的事情,我可以不做事!

网络方法还击了一名JSON的物体。

{>d”:“[{>validDetails”:“True”,“lateAlert”:“”,“LoginResponse”:“Jamie的行文记录,16:53请等”}

这是从火烧中显示的产出。 我不相信<条码>是什么,但与它有关系......

复兴共和与民主军呼吁并试图作出这一反应:

$("form").on("submit", function () {
    var LogonObject = new Object;
    LogonObject.password = $( #password ).val();
    var LogonData = JSON.stringify(LogonObject);

    $.ajax({
        type: "POST",
        url: "/logIn.aspx/login_try",
        data: LogonData,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {
            var results = (data.d);
            $( #LoginResponse ).html(results); // this is a Div to display the result
        }
    });
});

如果我这样做的话,那么唯一的记录仪显示:

[{>validDetails”:“True”,“lateAlert”:“”,“LoginResponse”:“Jamie的行文记录,16:53年,请等”}

看起来我喜欢一个快乐的JSON目标!

我无法研究如何达到下一个水平。

比如,我如何获得有效尾料、迟发等成果价值?

I have tried:

$.each(results, function (index, element) {
    $.each(element, function (index, sub) {
      alert(sub);
     });
});

在谷歌和SO中发现的图象I的其他几个变式,但似乎将<代码>results变量作为示意图而不是阵列处理,而我收到的输出是每一特性,即:

[, {, ", v, a, l, i, d, D... etc

So I wondered if results needed to be converted to JSON again (though I don t know why) so I tried

http://www.parseJSON(data.d)

But that didn t work either.

我确信,我在这里失踪的人确实很简单,但我可以说明如何这样做!

EDIT, 产生对策的代码(排除逻辑吨数,但这是重要的轨道):

Public Class OutputObject
    Public validDetails, lateAlert, LoginResponse As String  content of JSON output 
End Class

<System.Web.Services.WebMethod()> _
Public Shared Function login_try(password As String)

    Dim outputArray As New ArrayList

    Dim Login As New OutputObject()
    Login.validDetails = validDetails
    Login.lateAlert = lateAlert
    Login.LoginResponse = LoginResponse
    outputArray.Add(Login)

    serializer = New JavaScriptSerializer()
    Return serializer.Serialize(outputArray)

end function
最佳回答

I believe the error is somewhere in your JSON serialization (because you JSON looks like it has be serialized twice). Can we get the code that does that?

问题回答

警报发生的情况(底线);





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签