[英]Not getting all data when making .ajax call
我正在尝试从生成以下对象的页面获取数据,该对象在body和pre标签中显示为文本,但似乎没有获取所有4个键|值对(仅3个)?
请注意,我已经更改了jSON输出的URL,并删除了大部分数据以在此处将其缩短。 希望我没有引入任何错误。
{"nodes":[{"node":{"title":"NLT bottle 14","bottle_code":"NL_T14","bottle_img":"http:\/\/site.dev\/files\/bottles\/bottleimages\/nlt%20bottle%2014_bottle.jpg","swatch":"http:\/\/site.dev\/files\/bottles\/swatches\/nlt-bottle-14_swatch.jpg"}},{"node":{"title":"DS Bottle 033","bottle_code":"DS_033","bottle_img":"http:\/\/site.dev\/files\/bottles\/bottleimages\/ds%20bottle%20033_bottle.jpg","swatch":"http:\/\/site.dev\/files\/bottles\/swatches\/ds-bottle-033_swatch.jpg"}}]}
我正在尝试通过以下方式获得它:
var url = "http://site.dev/getinfo";
$.ajax({
url: url,
type: "GET",
dataType: "json",
async: true, // false loads and processes the data (function) before rendering the page
success: function(stuff){
console.log(stuff); // <- This output of the stuff object->nodes does not show the swatch key value pair!
process_data(stuff);
},
complete: function(){
doneprocess();
},
error: function(code){
error_get_data(code);
}
});
但是我没有色键/值对。 我不知道为什么!
{"nodes":[{"node":{"title":"NLT bottle 14","bottle_code":"NL_T14","bottle_img":"http://site.dev/files/bottles/bottleimages/nlt%20bottle%2014_bottle.jpg"}},{"node":{"title":"DS Bottle 033","bottle_code":"DS_033","bottle_img":"http://site.dev/files/bottles/bottleimages/ds%20bottle%20033_bottle.jpg"}}]}
非常感谢您的专业知识!
由于您无法处理我们无法分辨的数据,因此一个明显的问题是:您确定JSON数据结构有效吗?
与Web Inspector或Firebug一起检查浏览器是否正在获取与服务器认为相同的数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.