Skip to content

Instantly share code, notes, and snippets.

@sohel-rana
Last active December 20, 2015 13:29
Show Gist options
  • Select an option

  • Save sohel-rana/6138956 to your computer and use it in GitHub Desktop.

Select an option

Save sohel-rana/6138956 to your computer and use it in GitHub Desktop.
Example of sending array of objects in ExtJS ajax requests.
var users = [];
var data1 = {
name: 'sohel'
age: 30
editor: 'phpstorm'
};
var data2 = {
name: 'Riad'
age: 25
editor: 'netbeans'
};
users.push(data1);
users.push(data2);
Ext.Ajax.request(function(){
url : 'someurl.php'
jsonData : users, //this is the trickypart
success : function(response){
},
failure : function(response){
},
})
<?php
//get the payload
$input = file_get_contents('php://input');
$data = json_decode($input, true);
foreach($data as $d){
//do something
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment