My HTML page allows the user to create a list of items that get appended to a table. For simplicity lets say each item has 2 things. 1) a description and 2) a price. I also add this list of items into an object that I want to submit to a server. An example of an object created with 3 items would looks like
myObject = {
"Item1":["description1", "price1"],
"Item2":["description2", "price2"],
"Item3":["description3", "price3]
}
What is the correct way to submit this data to the server. The only way I am sure of is to append this object to a hidden form. Is there another way.
I am using nodejs with an expressjs framework if that helps. I then input this into a MySQL database by iterating over the object. Thank you.
Using JQuery:
var obj = { ... };
$.ajax({
type: "POST",
url: "your/url",
data: obj
});
试试这个: JSON.stringify(yourData)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.