Category Archives: JSON

jQuery & Javascript – Read JSON files on server

Here is an simple project which demonstrate how to read a JSON file in jQuery and Javascript.

Project structure

- (webroot folder)
  - data
    - file-1.json
    - file-2.json
  - js
    - script.js
  - index.html

Continue reading jQuery & Javascript – Read JSON files on server

Advertisement

jQuery & JSON – Make Cross Domain Request Using jQuery.getJSON() with JSONP

A few days ago i posted an article about making a JSON request using $.getJSON().
jQuery & JSON – Make JSON GET request using jQuery.getJSON()

But i have made a mistake there because i didn’t realize the Cross Domain problem. So this article shows you how to resolve the Cross Domain issue in $.getJSON() by JSONP. Continue reading jQuery & JSON – Make Cross Domain Request Using jQuery.getJSON() with JSONP

jQuery & JSON – Make JSON POST request using jQuery.post()

We can also make JSON POST request using the jQuery.post() function. If you want to use GET request. please refer to the previous post.
jQuery & JSON – Make JSON GET request using jQuery.getJSON()

 
Update @ 2011-10-13: This example does not work for Cross Domain POST request since the Current jQuery version(1.6.4) does not allow a Cross Domain POST request. For more information, you can refer to Mark Needham – jQuery: $.post, ‘jsonp’ and cross-domain requests

So if you want to make a Cross Domain GET request. Take a look on the following post.
jQuery & JSON – Make Cross Domain Request Using jQuery.getJSON() with JSONP

 
Here is the new server.php Continue reading jQuery & JSON – Make JSON POST request using jQuery.post()

jQuery & JSON – Make JSON GET request using jQuery.getJSON()

The following example makes a HTTP GET request with a JSON input and return the corresponding JSON object.

 
Update @ 2011-10-12: The example here does not support cross domain request. In other words, the server.php and json-get.php have to be inside the same domain. (ex. localhost) Thanks dskanth for pointing out the problem.
jQuery & JSON – Make Cross Domain Request Using jQuery.getJSON() with JSONP

 
Add the following 2 files to your web server
server.php Continue reading jQuery & JSON – Make JSON GET request using jQuery.getJSON()