I'm a student and a real beginner with jQuery and I want to know how to make that jQuery.getJSON()
read a local file and then print it in a modal (Bootstrap)
here's my local file (fruits.json)
{
Name: “Apple”,
Image: “./img/imag_apple.jpg”,
Description: “Tasty Apple”,
PriceKG: 34,
Taxes: 16,
Number: 28
}
{
Name: “Orange”,
Image: “./img/imag_orange.jpg”,
Description: “Tasty Orange”,
PriceKG: 34,
Taxes: 16,
Number: 28
}
{
Name: “Lime”,
Image: “./img/imag_lime.jpg”,
Description: “Tasty Lime”,
PriceKG: 34,
Taxes: 16,
Number: 28
}
You add grab the data from the response of getJSON()
and then add that to your modal.
jQuery.getJSON(url, function (data) {
var jsonObj = JSON.stringify(data);
// add data to modal
});