开发者

Import data w/json into jquery

Sorry this is probably simple but I am new to this and I cant find any documentation that makes sense. I have a link to json that I need to bring into a list for a jquery carousel

{"products":
[{"name":"gadget",
"id":{"id":"g123",
"vendorCode":"qqw234",
"vendorSku":"g223"},

Everything I try comes up blank or no data found.

Added from answer:

just listed part of it to show how it is formated. I can pull the data fine using php so I know the link is OK

This is what I want to do;

$.getJSON(http://mylink.com, function(data){ $.each(data.items, function(i,item){ $("").attr("src", item.products.image).appendTo("#images") .wrap("
"); }); $("#products.name").html(data.title); $("#products.description").html(products.description); $("#products.productLink").html("Details
");

Something is wrong though -I've been staring at it all day - I am sure it is simple but I can't see it ARG I don't know what I'm doing. Is this right: item.products.image?

I am开发者_如何学编程 trying to get it into a list so I can use jquery carousel


Use getJSON() like this:

$.getJSON('path/to/file', function(response){
  // response is a variable containing the JSON object, if it fetched it successfully
});


{} creates an object [] creates an array

The code you posted is doesn't show where the object and array ends. If you post a more complete example it will help to find the bugs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜