sending JSON to php via ajax | |
---|---|
Subject: | |
example string var items = {}; items = { 'items':[ {'product':'its name','qty':3}, {'product':'another name','qty':2} ] }; ajax call: JSON.stringify(items) $.ajax({ type: 'post', url: '/registration/assets/php/payment/', data: '&invoice-items='+JSON.stringify(items)+'......', dataType: 'json', back end file $obj = json_decode($_POST['invoice-items']); foreach ($obj->items as $items) { var_dump($items->product); } | |
2017-04-28 12:50:31 | gstlouis |
example string var items = {}; items = {'items': [ { 'product':'its name','qty':3} , ajax call: JSON.stringify(items) $.ajax( { type: 'post', back end file $obj = json_decode($_POST['invoice-items']); foreach ($obj->items as $items) { | gstlouis |
2017-04-28 12:52:51 | |
in order to build the json string in the front end dynamically | gstlouis |
2017-04-28 15:54:20 | |