Last active
December 20, 2015 13:29
-
-
Save sohel-rana/6138956 to your computer and use it in GitHub Desktop.
Example of sending array of objects in ExtJS ajax requests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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){ | |
| }, | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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