JSON introduction, AJAX post JSON data in PHP



JSON: JavaScript Object Notation.
JSON is smaller than XML and easy to parse.
JSON format:
a name followed by colon, followed by a value, such as
“fruit”:”apple”
i.e fruit = “apple”
JSON object using curly bracket
var temp={“fruit”:”apple”, “juice”:”orange”}
To access JSON object value:
temp.fruit, temp.juice
JSON array using square bracket:
var JSONarray= {
“food”:[
{“fruit”:”apple”, “juice”:”orange”},
{“fruit”:”banana”, “juice”:”watermelon”}
]
}

To access the value apple in…

, , , , , ,

2 thoughts on “JSON introduction, AJAX post JSON data in PHP

  1. nice tutorial
    but

    dataType: "JSON",
    success:function(jsonStr)
    {
    $('#result').text(JSON.stringify(jsonStr));
    }

    is not showing the data.

    when i have changed data type json to html its showing some thing but json data type is not working ..moreover rest of the thing is fine.

Leave a Reply

Your email address will not be published. Required fields are marked *