jquery 1.5 ajax请求是错误的

时间:2011-02-18 19:37:07

标签: php json jquery jquery-validate jquery-1.5

尝试升级到jQuery 1.5并且所有的ajax调用都会中断。我正在运行firefox,它给了我一个无效Label的javescript错误 我正在使用php的json_encode 这是我的json回复

{
    "page": "1",
    "total": 9651,
    "rows": [
        {
            "cell": [
                "story",
                "51438",
                "Skin color: Handy tool for teaching evolution",
                "2011-02-20 08:30:26"
            ]
        },
        {
            "cell": [
                "story",
                "51435",
                "Photosynthesis may hold key to production of cheap hydrogen for fuel",
                "2011-02-19 10:00:03"
            ]
        },
        {
            "cell": [
                "story",
                "51478",
                "Dancers, supporters ready for THON 2011 Feb. 18-20 at Jordan Center",
                "2011-02-18 14:26:25"
            ]
        },
        {
            "cell": [
                "story",
                "51420",
                "Juggling languages can build better brains",
                "2011-02-18 13:30:44"
            ]
        },
        {
            "cell": [
                "story",
                "51434",
                "Multiple approaches necessary to tackle world's food problems",
                "2011-02-18 13:30:44"
            ]
        },
        {
            "cell": [
                "story",
                "51436",
                "U.S. will no longer dominate science and research, study finds",
                "2011-02-18 13:00:49"
            ]
        },
        {
            "cell": [
                "story",
                "51492",
                "NPR to air interview with Penn State professor today (Feb. 18)",
                "2011-02-18 11:20:10"
            ]
        },
        {
            "cell": [
                "story",
                "51437",
                "Research universities play a major role in national security",
                "2011-02-18 10:30:28"
            ]
        },
        {
            "cell": [
                "story",
                "51472",
                "Paterno's necktie from 400th win nets $10,200 for Public Broadcasting",
                "2011-02-18 09:20:52"
            ]
        },
        {
            "cell": [
                "story",
                "51363",
                "PSU Extension offers free tax preparation help for low-income families",
                "2011-02-18 01:32:04"
            ]
        },
        {
            "cell": [
                "story",
                "51477",
                "Students set to produce complete THON coverage, including webcast",
                "2011-02-17 15:24:47"
            ]
        },
        {
            "cell": [
                "story",
                "51385",
                "The Medical Minute: Seasonal Affective Disorder",
                "2011-02-17 12:27:30"
            ]
        },
        {
            "cell": [
                "story",
                "51345",
                "Abington professor's new book exposes NBA betting scandal",
                "2011-02-17 11:59:31"
            ]
        },
        {
            "cell": [
                "story",
                "51360",
                "Student Stories: Statistical service internship makes it all add up",
                "2011-02-17 11:12:32"
            ]
        },
        {
            "cell": [
                "story",
                "51453",
                "Parking Office announces parking, transit changes related to THON",
                "2011-02-17 11:02:46"
            ]
        },
        {
            "cell": [
                "story",
                "51444",
                "Penn State's Lunar Lion team aims to land vehicle on moon by 2015",
                "2011-02-17 08:17:12"
            ]
        },
        {
            "cell": [
                "story",
                "51427",
                "Students flock to Spring Career Fair",
                "2011-02-16 12:56:27"
            ]
        },
        {
            "cell": [
                "story",
                "51419",
                "Ice Campaign receives $1 million gift from Paul and Nancy Silvis",
                "2011-02-16 10:51:45"
            ]
        },
        {
            "cell": [
                "story",
                "51353",
                "CarbonEARTH program facilitates science education, teaching",
                "2011-02-15 15:59:04"
            ]
        }
    ],
    "messages": null
}

所有这些在jquery 1.4.2

中都能正常工作

我想我必须等待升级,但我想我会检查一下其他人是否有解决方案?

3 个答案:

答案 0 :(得分:2)

好的,所以我在搜索后找到了正确的解决方案,我找到了bug report的jQuery Validate。在报告的底部,validate的作者提供了一个分叉版本,可以解决问题,感谢所有人的帮助

答案 1 :(得分:1)

这是一个错误,它在1.5.1中修复。查看票证http://bugs.jquery.com/ticket/8125,您可以在http://code.jquery.com/jquery-git.js

找到最新的jQuery版本,其中包含最新的修补程序。

您还可以根据此帖子JQuery 1.5 and new "Text JSON" datatype

尝试jQuery.ajaxSetup({ jsonp: null, jsonpCallback: null});

答案 2 :(得分:1)

最有可能是因为jquery.validate.js中的错误。有一个快速(不推荐!)修复jQuery.ajaxSetup({ jsonp: null, jsonpCallback: null}); - 如果它适合您,请进一步查看版本1.5中“{无效标签”问题的there is a discussion的不同选项。