How to import data with JSON?

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

Was this solution helpful to you?

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:

Just Added Q & A:

Find solution

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.