收到此错误" $ .toJSON不是一个函数" [英] getting this error " $.toJSON is not a function "

查看:286
本文介绍了收到此错误" $ .toJSON不是一个函数"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用jQuery和Ajax和我用这个方法。但我得到的错误$ .toJSON是不是在我的萤火功能。问题出在哪里?我使用jQuery 1.3.2。谢谢

  $(文件)。就绪(函数(){
        $(#S1)。点击(函数
            (){
            $(#T1)的slideToggle(快)。
            $(#S1)的CSS(背景色,黄)。
            VAR ID = $(#HiddenField2)ATTR(值)。
            VAR PARAMS =新的对象();
            params.Key = ID;
            $阿贾克斯({
                键入:POST,
                网址:viewMessages.aspx /读进来,
                数据:$ .toJSON(PARAMS)
                的contentType:应用/ JSON
                数据类型:JSON,
                成功:函数(){

                }
            });
        });
    });
 

解决方案

这是正确的。

没有 $的toJSON()功能:的http:// api.jquery.com/jQuery.toJSON 。也许你想使用 JSON.stringify() 代替。

I'm trying to use jQuery and Ajax and I use this method. but I get the error $.toJSON is not a function in my firebug . where is the problem? I use jquery 1.3.2 . thanks

  $(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 () {

                }
            });
        });
    });

解决方案

That's correct.

There is no $.toJSON() function: http://api.jquery.com/jQuery.toJSON. Perhaps you want to use JSON.stringify() instead.

这篇关于收到此错误" $ .toJSON不是一个函数"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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