且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JSON.parse:意外的角色

更新时间:2022-05-18 21:57:58

您不需要将 $。parseJSON 自动调用为jQuery这样做是因为如果你没有指定 dataType 属性,jQuery会尝试猜测它并调用正确的函数来解析响应,然后将数据处理成成功函数

You don't need the $.parseJSON call as jQuery automatically does it because if you don't specify a dataType property jQuery tries to guess it and calls the correct function to parse the response before the data is handled to the success function

   $.ajax({
        type: 'POST',
        url:$(this).attr('action'),
        data:$(this).serialize(),
        success:function(data)
        {
          //console.log("SUCCESS " + data);
          var json_cli = data;
        }
    })

也请查看此问题为什么'jQuery.parseJSON'没有必要?