JQuery and json

Here I want to learn and do. I have a JSON file containing my product and details (size, color, description). On the website I can not use PHP and MySQL, I can only use Javascript and HTML. Now I want JQuery so that I can read and write a JSON file (the JSON file will serve as my database). I'm not sure if this can be done using only jQuery and JSON.

  • First, how to request a JSON file? (Example: I would look for the name and color of the product.)

  • How to parse JSON data that was found in HTML?

  • How to add product details to a JSON file?

It will also be great if you can point me to a good tutorial about my questions.

I am new to jQuery and JSON.

Thank!

+1
source share
1 answer

Javascript , JSON , Javascript. .

JSON . jQuery.getJSON. URL-, ( , , ). URL- JSON , , .

, . , JSON, "", "" "", :

$.getJSON("getProductJSON.htm",
    function(data) {
        $.each(data.products, function(i, item) {
            var name = item.name;
            var price = item.price;
            // now display the name and price on the page here!
        });
    }, 
);

, $.getJSON JSON , . $.each JSON.

+6

All Articles