I append my localstorage data in formData
let products = []; for (i = 0; i < localStorage.length; i++) { x = localStorage.key(i); if (x !='debugbar-time-new' && x !='debugbar-time') { item = JSON.parse(localStorage.getItem(x)) products.push({'_id' : item['_id'] , 'title':item['title'], 'quantity':item['quantity']}); } } formData.append('products',JSON.stringify(products))
now my data in this form
products, [{"_id":5,"title":"bicycle","quantity":1},{"_id":2,"title":"i7","quantity":3},{"_id":4,"title":"i5","quantity":1},{"_id":1,"title":"i5","quantity":37},{"_id":3,"title":"i7","quantity":1}]
I get data in my controller
$req = $this->request->getVar('products');
I receive data in encoded form. How do I convert it in array and other forms?
https://stackoverflow.com/questions/65846760/how-localstorage-data-append-in-formdata January 22, 2021 at 10:11PM
没有评论:
发表评论