jeudi 3 avril 2014

Not Able to Pase JSON Object with $.ajax() Method


Vote count:

0




I am trying to parse a JSON object (Not Stored on a File) by using $.ajax() methos but it is not functionoing! can you please let me know what i am doing wrong?



var painting = [
{
"title": "Boardwalk 5",
"artist": "Arnie Palmer",
"image": "ap1.jpg",
"price": 850
},
{
"title": "A Lasting Piece",
"artist": "Arnie Palmer",
"image": "ap2.jpg",
"price": 450
},
{
"title": "Surf at High Tide",
"artist": "Arnie Palmer",
"image": "ap3.jpg",
"price": 950
},
{
"title": "The Games We Play",
"artist": "Arnie Palmer",
"image": "ap4.jpg",
"price": 850
}
];
$(document).ready(function () {
$.ajax({
type: 'GET',
url: 'painting',
dataType: 'json',
success: jsonParser
});

});

function jsonParser(json) {
$.getJSON(painting, function(data){
$.each(painting, function(k,v){
var title = v.title;
var price = v.price;
$('#container').append('<div class="painting"><br/><div class="title">' + title + '<br/>$' + price + '</div></div>')
});
});
}


asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire