jquery 1.5 ajax requests are erroring

不想你离开。 提交于 2019-12-02 18:30:06

问题


trying to upgrade to jQuery 1.5 and all my ajax calls break. I'm running firefox and it gives me a javescript error of invalid Label I'm using php's json_encode here is my json response

{
    "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
}

all this works fine in jquery 1.4.2

think I'll have to wait to upgrade but thought I would check and see if anyone else had a solution ?


回答1:


Ok so I found the correct solution after some searching I found a bug report for the jQuery Validate. At the bottom of the report the author of validate provides a forked version which fixes the problem thanks to all for help




回答2:


Most probably it happens due to a bug in jquery.validate.js. There is a quick (not recommended!) fix jQuery.ajaxSetup({ jsonp: null, jsonpCallback: null}); - if it works for you, look further into different options, there is a discussion of "Invalid Label" problem in version 1.5.




回答3:


This is a bug and it is fixed in 1.5.1. See ticket http://bugs.jquery.com/ticket/8125, You can find the latest jQuery release with up to date fixes at http://code.jquery.com/jquery-git.js

You can also try jQuery.ajaxSetup({ jsonp: null, jsonpCallback: null}); as per this thread JQuery 1.5 and new "Text JSON" datatype



来源:https://stackoverflow.com/questions/5045745/jquery-1-5-ajax-requests-are-erroring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!