Ajax调用,收到JSON时出错

时间:2014-04-08 08:56:19

标签: jquery asp.net ajax json

我正在开发一个ASP.net应用程序。我通过Ajax调用(jQuery)将数据从客户端发送到服务器。服务器通过具有属性[WebMethods]的方法接收所有调用(注意:我的应用程序托管在SharePoint 2010 Foundation中)。

当我从服务器收到大量数据时,Ajax调用无法正常工作。

如何解决此问题?

由于

[编辑 - 添加了示例代码和其他]

我的迟到反应的借口(我非常致力于工作)。我像那段代码一样执行我的Ajax调用:

    $.ajax({
        type: "POST",
        url: "../_layouts/MyApplication/MasterPage.aspx/GetMyData?nameParameter="+value,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: "{}",
        cache: false,
        success: function (result)
        {
           //More code
        }
      });}

服务器端代码是这样的:

    [WebMethod]
    public static string GetMyData()
    {
        // Variables
        List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();

        // Connection
        try
        {
            // Getting data from database
        }
        catch (Exception ex)
        {
            log.Error("Error GetMyData: " + ex.Message);
        }
        finally
        {
            objSqlConnection.Close();
        }

        // Serializer and return
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        string json = serializer.Serialize(rows);
        return json;
    }

由于

2 个答案:

答案 0 :(得分:0)

请求大小可能超过IIS中设置的限制。您可以看到类似的案例here

答案 1 :(得分:0)