【问题标题】:jquery 1.5 ajax requests are erroringjquery 1.5 ajax 请求出错
【发布时间】:2011-02-18 19:37:07
【问题描述】:

尝试升级到 jQuery 1.5 并且我所有的 ajax 调用都中断了。我正在运行 firefox,它给了我一个无效标签的 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 中都可以正常工作

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

【问题讨论】:

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


    【解决方案1】:

    好的,经过一番搜索,我找到了正确的解决方案,我找到了 jQuery Validate 的 bug report。在报告的底部,validate 的作者提供了一个分叉版本,感谢大家的帮助解决了这个问题

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 到目前为止,如果我取出 jQuery.validate.js,问题也会消失,您给我的修复程序也解决了问题,我现在要查看您链接到的讨论。
      • 您能告诉我使用您的修复程序的缺点是什么吗?
      • @mcgrailm - 如果您需要使用 jsonp 进行混搭等,这会妨碍您。有关 JSONP 的更多信息:[ibm.com/developerworks/library/wa-aj-jsonp1/]
      【解决方案3】:

      这是一个错误,已在 1.5.1 中修复。见票http://bugs.jquery.com/ticket/8125,你可以在http://code.jquery.com/jquery-git.js找到带有最新修复的最新jQuery版本

      您也可以尝试jQuery.ajaxSetup({ jsonp: null, jsonpCallback: null}); 按照这个帖子JQuery 1.5 and new "Text JSON" datatype

      【讨论】:

      • -git 版本无法解决问题。
      猜你喜欢
      • 2011-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-26
      • 2012-07-11
      • 1970-01-01
      • 1970-01-01
      • 2012-04-22
      相关资源
      最近更新 更多