I would like to know how to print a json object with a specific id to a div?! My json file looks like this (shortened) and is automatically generated by a webshop program I use:
"shipping":{
"methods":{
"core|13490|40699":{
"id":"core|13490|40699",
"price":{
"price_excl":"0.0000","price_incl":"0.0000"
}
},
"core|10292|40695":{
"id":"core|10292|40695",
"price":{
"price_excl":"21.0084","price_incl":"25.0000"
}
}
}
},
and my script like this:
window.onload = function(){
$.getJSON('http://shop.com/cart/?format=json', function(data){
$.each(data.cart.shipping.methods, function(index, method){
$('<span></span>')
.html('<strong>' + method.price.price_incl + '</strong>')
.appendTo('.cart-shipping');
});
});
};
What i try to archieve is that only the shipping price of shipping method with id "core|10292|40695" is shown. With the code I have both shipping prices are shown. Further I would like to know how to format those prices into ' real' prices instead of 25.000.
I'm pretty new to JSON, jquery/ajax as you probably can see, but I'm willing to learn. The above I archieved with searching this site but my question is something I really can't figure out.