Jquery 1.6.2不支持数据类型:json


Jquery 1.6.2 Doesnt work with datatype : json

我正在制作一个注册表单,其中我使用了以下函数来验证注册,当表单试图提交时调用该函数。

$.ajax({
    type: "POST",
    url: "view/ajax/php/checkcap.php",
    data: $('#capform').serialize(),
    dataType: "json",
    async: false,
    success: function(msg){
        alert(msg.txt);
        // other validations
    }
})

这里的alert只是用于显示checkcap.php文件的响应。它可以完美地与jquery 1.3.2一起工作,但是我已经将jquery 1.3.2升级到1.6.2。在使用jquery 1.6.2之后,函数从PHP文件(使用firebug检查)获得响应,但不能显示消息(来自PHP文件的响应)。如何使代码工作与jquery 1.6.2 ?

确保json格式为

{
  "one": "Singular sensation",
  "two": "Beady little eyes",
  "three": "Little birds pitch by my doorstep"
}
http://api.jquery.com/jQuery.getJSON/

属性名上缺少双引号

{"status":0,"txt":"a"}   ---correct
{status:0,txt:"a"}       ---wrong