IE 8上的Page Method调用的Json问题. [英] Json problem with Page Method call on IE 8.

查看:77
本文介绍了IE 8上的Page Method调用的Json问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,通过Page方法,使用ajax调用中的值填充select元素.在FF中,代码可以完美运行,在IE8中,我收到错误消息:"ResourceList [...].id"为null或不是对象.我在这里可以看什么?

I have the following code that populates a select element with values from an ajax call, via a Page Method. In FF, the code works perfectly, in IE8 I get the error: ''ResourceList[...].id'' is null or not an object. What can I look at here?

function readShift(jsonString) {
    var shiftInfo = Sys.Serialization.JavaScriptSerializer.deserialize(jsonString);
    var listItems = "";
    listItems += "<option value='0'>[Unassigned]</option>";
    for (var i = 0; i < shiftInfo.ResourceList.length; i++) {
        listItems += "<option value='" + shiftInfo.ResourceList[i].id + "'>" + shiftInfo.ResourceList[i].name + "</option>";
    }
    $("#" + resourceListId).html(listItems);
 };

推荐答案

(" + resourceListId).html(listItems); };
("#" + resourceListId).html(listItems); };


首先,您应该在IE8中调试JavaScript并查看shiftInfo的结构.比我想您会明白这是怎么回事.

但是首先要考虑的也许是更重要的事情是,为什么要首先在JavaScript中执行JSON反序列化.如果正确使用了Microsoft ASP.NET Ajax框架,则在调用page方法之后,根本不必像在回调方法中那样去做,您应该已经反序列化了JavaScript对象.由于您调用了反序列化,因此我将开始在jsonString中寻找问题.

同样从体系结构的角度来看,问题似乎出在您的C#代码而不是JavaScript中.
First, you should debug you JavaScript in IE8 and see the structure of the shiftInfo. Than I presume you''ll understand what''s wrong.

However the first and may be more important thing to think about is why you perform JSON deserialization in JavaScript on the first place. If you utilize the Microsoft ASP.NET Ajax framework correctly you don''t have to do that at all as in the callback method after you called your page method you should have your JavaScript object already deserialized. Since you call deserialize I''d start looking for a problem in the jsonString.

Also from the architectural point of view it seems like the problem starts in your C# code rather than in JavaScript.


这篇关于IE 8上的Page Method调用的Json问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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