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
-
Answer:
Use http://api.jquery.com/jQuery.getJSON/ like this: $.getJSON('path/to/file', function(response){ // response is a variable containing the JSON object, if it fetched it successfully });
mark at Stack Overflow Visit the source
Other answers
{} 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.
minboost
Related Q & A:
- How to set value in the dropdown from a JSON data list?Best solution by Stack Overflow
- How do I create an HTML table, in jQuery, with JSON data?Best solution by Stack Overflow
- How to store json data in jquery?Best solution by Stack Overflow
- How to read Json Data from online file?Best solution by mkyong.com
- How to deal with dynamic JSON data using AngularJS?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.