Reputation: 1150
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.
Upvotes: 2
Views: 106
Reputation: 9576
Using JQuery:
var obj = { ... };
$.ajax({
type: "POST",
url: "your/url",
data: obj
});
Upvotes: 1