hi every one today i am going to start session 7 .
let us know some short review on JSON
what is JSON.
if you look at above example you can see declaration of object to variable in short declare, store , transfer in DOM this are main working of JSON.
above example uses json parse method,
what is json parse???
in above figure shows how json parse working.
now let us see JSON with php
you can comment if any improvement wants or if you want discuss any specific topic.
please share with your friends & all . thanks for viewing this blog. will see more detail in next session.
let us know some short review on JSON
what is JSON.
JSON: JavaScript Object Notation.
JSON -- > a syntax for storing and exchanging data.
JSON ---> text, written with JavaScript object notation.
JSON -- > a syntax for storing and exchanging data.
JSON ---> text, written with JavaScript object notation.
var abc = '{ "age":26, "city :PUNE",''name:siddhanam" }';
var anobj = JSON.parse(myJSON);
document.getElementById("abc").innerHTML = myObj.name;
<h2>Convert a string written in JSON format, into a JavaScript object.</h2>
<p id="abc"></p>
var anobj = JSON.parse(myJSON);
document.getElementById("abc").innerHTML = myObj.name;
<h2>Convert a string written in JSON format, into a JavaScript object.</h2>
<p id="abc"></p>
if you look at above example you can see declaration of object to variable in short declare, store , transfer in DOM this are main working of JSON.
above example uses json parse method,
what is json parse???
common use of JSON is to exchange data to/from a web server. When receiving data from a web server, the data is always a string. Parse the data with JSON.parse(), and the data becomes a JavaScript object.
now let us see JSON with php
<!DOCTYPE html>
<html>
<body>
<h2>Example of JSON.</h2>
<p id="abc"></p>
<script>
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText);
document.getElementById("demo").innerHTML = myObj[2];
}
};
xmlhttp.open("GET", "trial.php", true);
xmlhttp.send();
</script>
</body>
</html>
<html>
<body>
<h2>Example of JSON.</h2>
<p id="abc"></p>
<script>
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText);
document.getElementById("demo").innerHTML = myObj[2];
}
};
xmlhttp.open("GET", "trial.php", true);
xmlhttp.send();
</script>
</body>
</html>
in above code there is getting result of trial.php file and assign value to demo div.
suppose you type an address in trial.php or anything data by using this xmlhttp request & get method browser will show result.
json is not need any external installation .
our aim is to gain & share more & more knowledge.suppose you type an address in trial.php or anything data by using this xmlhttp request & get method browser will show result.
json is not need any external installation .
you can comment if any improvement wants or if you want discuss any specific topic.
please share with your friends & all . thanks for viewing this blog. will see more detail in next session.