json Uncaught SyntaxError:意外的令牌,(逗号)

时间:2015-05-18 09:57:17

标签: jquery ajax jsonp

首先,我知道有很多类似的问题,其中非法角色是":"或"<" ,但我找不到一个非法字符是逗号的地方:

Uncaught SyntaxError: Unexpected token ,

我已经摆弄了jQuery ajax设置,我收到了大约50%的请求的上述错误。很奇怪,有些人工作,有些人不对,对吧?

这是我的JS:

            var url = "http://" + domain + "/NewsRoomContentsSvc.svc/getNewsRoomData/" + newsRoomId + "/" + skip + "/" + take + "/" + logged;

        var request = $.ajax({
            type: "GET",
            url: url,
            contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
            crossDomain: true,
            dataType: "jsonp",
            //jsonp:"callback",
            //jsonpCallback:"doNewsRoom",
            newsRoomId: newsRoomId,
            newsroom: newsroom,
            newsRoomParentId:newsRoomParentId,
            cache: false 
        });

        request.done(function (data, textStatus, jqXHR) {

            if (data)
            {
                var CarouselContainer = $("<ul style='width:55000px;'></ul>");
                buildNewsRoom(newsroom, CarouselContainer, data, newsRoomRows, newsRoomCols, newsRoomId, isFull, false);

            }
            else
            {
                //showErrorMsg("hmmmm, no data...");
            }
        })

        request.fail(function (jqXHR, textStatus, errorThrown) {
            if(jqXHR.responseText!=="") 
                showErrorMsg(jqXHR);
           // return false;
        })

我的回归JSONP对我来说很好看:

http://ec2-54-76-106-247.eu-west-1.compute.amazonaws.com/NewsRoomContentsSvc.svc/getNewsRoomData/24306184/0/10/1?callback=jQuery1102014052710216492414_1431942943848&_=1431942943849

有一半时间它遇到带有错误的request.fail方法 &#34; jQuery1102014052710216492414_1431942943848未被调用&#34;

任何建议都将不胜感激

1 个答案:

答案 0 :(得分:0)

json无效:

   jQuery1102014052710216492414_1431942943848({"NewsRoomArticles":[{"ArticleId":26539256,"FeedId":, ....}

属性"Comments":"Discussions""FeedId":需要更改数据库结构的值以包含默认值