首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >getJSON中的jQuery解析错误

getJSON中的jQuery解析错误
EN

Stack Overflow用户
提问于 2012-12-31 06:57:26
回答 1查看 847关注 0票数 0

在使用JSON搜索产品时,我遇到了ProductWiki解析错误。如果我遗漏了什么,或者返回的数据格式不正确,您能告诉我吗?

下面是我使用的JavaScript代码

代码语言:javascript
复制
var searchUrl = "http://api.productwiki.com/connect/api.aspx?" +
            "&op=search" +
            "&key=" + API_KEY_PRODUCT_WIKI +
            "&q=" + nugget +
            "&format=json" +
            "&jsoncallback=?";

 $.getJSON(searchUrl, function (data) { alert("Got data"); });

在执行代码时,我从productwiki获得了以下数据

代码语言:javascript
复制
{"__type":"ProductWiki.DataStructures.API.Schema.pw_api_results, ProductWiki.DataStructures, Version=1.0.4622.22636, Culture=neutral, PublicKeyToken=null","message":null,"num_results":2,"products":[{"__type":"ProductWiki.DataStructures.API.Schema.product, ProductWiki.DataStructures, Version=1.0.4622.22636, Culture=neutral, PublicKeyToken=null","url":"http://www.productwiki.com/microsoft-surface/","id":15113,"title":"Microsoft Surface","description":null,"proscore":"41","number_of_reviews":"13","category":"Computers","key_features":[],"images":[{"__type":"ProductWiki.DataStructures.API.Schema.image, ProductWiki.DataStructures, Version=1.0.4622.22636, Culture=neutral, PublicKeyToken=null","title":"Microsoft Surface","rawimage":"http://images.productwiki.com/upload/images/microsoft_surface.jpg","largeimage":"http://images.productwiki.com/upload/images/microsoft_surface-400-400.jpg","mediumimage":"http://images.productwiki.com/upload/images/microsoft_surface-100-100.jpg","smallimage":"http://images.productwiki.com/upload/images/microsoft_surface-60-60.jpg"}],"community_review":null,"reviews":null,"tags":null,"competitors":null,"related":null,"skus":null},{"__type":"ProductWiki.DataStructures.API.Schema.product, ProductWiki.DataStructures, Version=1.0.4622.22636, Culture=neutral, PublicKeyToken=null","url":"http://www.productwiki.com/menotek-flexible-bluetooth-waterproof-mini-keyboard/","id":59084,"title":"Menotek Flexible Bluetooth Waterproof Mini Keyboard","description":null,"proscore":"62","number_of_reviews":"1","category":"Keyboards","key_features":[],"images":[{"__type":"ProductWiki.DataStructures.API.Schema.image, ProductWiki.DataStructures, Version=1.0.4622.22636, Culture=neutral, PublicKeyToken=null","title":"Menotek Flexible Bluetooth Waterproof Mini Keyboard","rawimage":"http://images.productwiki.com/upload/images/menotek_flexible_bluetooth_waterproof_mini_keyboard.jpg","largeimage":"http://images.productwiki.com/upload/images/menotek_flexible_bluetooth_waterproof_mini_keyboard-400-400.jpg","mediumimage":"http://images.productwiki.com/upload/images/menotek_flexible_bluetooth_waterproof_mini_keyboard-100-100.jpg","smallimage":"http://images.productwiki.com/upload/images/menotek_flexible_bluetooth_waterproof_mini_keyboard-60-60.jpg"}],"community_review":null,"reviews":null,"tags":null,"competitors":null,"related":null,"skus":null}]}

但是它也抛出了jquery错误

代码语言:javascript
复制
JavaScript critical error at line 1, column 10 in http://api.productwiki.com/connect/api.aspx?&op=search&key=***&q=microsoftsurface&format=json&jsoncallback=jQuery18308245886188083906_1356907329390&_=1356907329577

SCRIPT1004: Expected ';'

我尝试在JSON Formatter & validator验证来自productwiki的响应,没有发现任何问题。想知道我是否遗漏了什么,或者是来自产品维基的数据格式不正确?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-04 10:33:27

我认为productwiki不支持jsonp。我最终从服务器端访问了他们的API

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14095558

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档