6

这是我第一次使用 JSON 的经验,所以我可能在做一些非常愚蠢的事情。

我构建了一个应用程序来抓取页面并返回一个 JSON 对象。

我返回的 JSON 如下所示(以 Facebook 为例):

{"urlTitle":"Welcome to Facebook \u2014 Log in, sign up or learn more","urlDescription":" Facebook is a social utility that connects people with friends and others who work, study and live around them. People use Facebook to keep up with friends, upload an unlimited number of photos, post links and videos, and learn more about the people they meet."}

但是,在 FireBug 中,我收到了上述错误(另见屏幕截图)。

我的 jQuery 代码通过 AJAX 获取 JSON,现在看起来很简单:

$("#submitButton").on("click", function(){ 


        $.ajax({

           url: '/miscellaneous/scrape/scrape.cfm',
           dataType: 'json',
           data: {
              strURL:  $.param( $("#submitURL").attr("value") )
           },
           type: 'POST',
           success: function(data) {
               alert("yes!");
           }

        });

    return false;

});

我从来没有收到我的成功信息:(只是错误!

我在这里做一些明显错误的事情吗?

谢谢,迈克尔。

在此处输入图像描述

编辑

这是我要求的整个 JSON:

{"urlTitle":"Welcome to Facebook \u2014 Log in, sign up or learn more","urlImages":{"image_8":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yb\/r\/GsNJNwuI-UM.gif","image_6":"http:\/\/photos-g.ak.fbcdn.net\/photos-ak-snc7\/v85005\/226\/255889644513526\/app_104_255889644513526_1061222291.png","image_7":"http:\/\/secure-us.imrworldwide.com\/cgi-bin\/m?ci=ent156564&am=3&ep=1&at=view&rt=banner&st=image&ca=cmp7747&cr=crv72918&pc=plc220331&r=1346702536","image_4":"http:\/\/photos-a.ak.fbcdn.net\/photos-ak-snc7\/v85006\/156\/156324174503268\/app_104_156324174503268_1504955413.png","image_5":"http:\/\/photos-b.ak.fbcdn.net\/photos-ak-snc7\/v85005\/78\/344521295633922\/app_104_344521295633922_1943760717.png","image_3":"http:\/\/photos-c.ak.fbcdn.net\/photos-ak-snc7\/v85005\/14\/298987460188718\/app_104_298987460188718_170436975.png","image_2":"http:\/\/photos-g.ak.fbcdn.net\/photos-ak-snc7\/v85006\/196\/287530028007964\/app_104_287530028007964_853932327.png","image_1":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yY\/r\/2LiCtrj0cdC.png"},"urlDescription":" Facebook is a social utility that connects people with friends and others who work, study and live around them. People use Facebook to keep up with friends, upload an unlimited number of photos, post links and videos, and learn more about the people they meet."}
4

1 回答 1

0

嗨根据您对问题的评论.. 看起来您正在寻找一种方法来避免 AJAX 请求进行缓存。为此,您可以尝试这样的事情..

$.ajax({
       url: url,
       data: inputs + '&ran=' + Math.rand(),
    )};

或者

$.ajaxSetup ({
    // Disable caching of AJAX responses
    cache: false
});

我希望这能帮到您。

于 2015-06-25T13:26:19.987 回答