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?
question from:
https://stackoverflow.com/questions/65846760/how-localstorage-data-append-in-formdata 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…