How to get JSON data through ajax in jPut

I found a useful jQuery plugin for appending JSON data to HTML contents in an easy way in this link Jput plugin

But I would like to know how it is possible to send and get json data thorugh ajax ? Please help me. Thanks in advance.

Upvotes: 3

Views: 577

Answers (3)

shabeer
shabeer

Reputation: 1064

//jPut Code
$('#list_div').jPut({
   ajax_url:'data.json', //json url
   ajax_data:data,            //data that you want to send
   name:'list'
});

Please download & go through the docs and samples

Upvotes: 5

Harish U Warrier
Harish U Warrier

Reputation: 606

Try this

$.getJSON({
  url: "test.php",
  data:data,

 success:function(response){


        $('#list_div').jPut({
            jsonData:data,  //json
            name:'list'     //jPut name
        },
});

Here test.php should return a json data

Upvotes: 5

Manjunath Hegde
Manjunath Hegde

Reputation: 414

For recieving from server

$.getJSON("sender_url",function(jsond){

  `alert(JSON.stringify(jsond));`

});

OR

$.post("sender_url",{},function(response){

  `var jsond=$.parseJSON(response);`

  `alert(JSON.stringify(jsond));`

});

for sending from client

var json=[{"id":1,"name":"name1"}{"id":2,"name":"name2"}{"id":3,"name":"name3"}];

$.post("target_url",json,function(reply){

  `alert(reply);

})

Example: target.php

<?php

print_r($_POST);

?>

Upvotes: 2

Related Questions