jquery - 出现此错误 "$.toJSON is not a function "

标签 jquery ajax json

我正在尝试使用 jQuery 和 Ajax,并且使用此方法。但我收到错误 $.toJSON is not a function in my firebug 。哪里有问题?我使用 jquery 1.3.2 。谢谢

  $(document).ready(function () {
        $("#S1").click(function 
            () {
            $("#t1").slideToggle("fast");
            $("#S1").css("background-color", "yellow");
            var ID = $("#HiddenField2").attr("Value");
            var params = new Object();
            params.Key = ID;
            $.ajax({
                type: "POST",
                url: "viewMessages.aspx/readen",
                data: $.toJSON(params),
                contentType: "application/json",
                dataType: "json",
                success: function () {

                }
            });
        });
    });

最佳答案

这是正确的。

没有$.toJSON()函数:http://api.jquery.com/jQuery.toJSON 。也许您想使用 JSON.stringify()相反。

关于jquery - 出现此错误 "$.toJSON is not a function ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7759619/

相关文章:

javascript - 如何将 HTML5 Canvas 保存为服务器上的图像?

php - java.lang.String类型的Android数据库无法转换为JSONObject

javascript - 调用函数仅一次返回 false 后,表单不执行提交

jquery - 在MVC 4中增加json响应maxJsonLength

javascript - 如何将选择复选框值动态传递给ajax调用变量动态发布到php变量

json - 休息 : different representations of the same data

java - 如何将 json 内容从 jackson 流式传输到 org.apache.http.entity.InputStreamEntity?

javascript - JSON - 无法读取未定义的属性 'viewers'

javascript - html改变时关联jquery回调

javascript - jquery 2 输入字段验证和成功提交后的 POST 1 值