jQuery Ajax
Next ❯JSON Eval
- jquery makes ajax more easy to use
- turned_in_notJSON via jQuery Ajax
In jquery
$.getJSON()
method, already converts JSON String into object. So, only for this jquery ajax method you don't have to useJSON.parse()
Below example, both your html and json files are in the same folder
"jsoncode.json" file<!DOCTYPE html> <html> <head><title>JSON Example via jQuery</title> <!--Required jQuery Library file--> <script src="jquery.min.js"></script> </head> <body> <p>Hi, My name is <span id="show"></span></p> <script> $.getJSON("jsoncode.json",function(result){ //Now you can show your result object as per your need $("#show").html(result.name); }); </script> </body> </html>
OUTPUT{ "name":"Riya","age":23 }
Hi, My name is
❮ Prev Ajax
Next ❯JSON Eval