gpt4 book ai didi

javascript - jQuery JSON 错误 : Syntax error, 无法识别的表达式

转载 作者:数据小太阳 更新时间:2023-10-29 05:39:00 25 4
gpt4 key购买 nike

这是我第一次使用 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;

});

我从未收到成功消息 :( 只是错误!

我在这里做错了什么吗?

谢谢,迈克尔。

enter image description here

编辑

这是我请求的整个 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."}

最佳答案

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

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

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

希望对您有所帮助。

关于javascript - jQuery JSON 错误 : Syntax error, 无法识别的表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12253314/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com