Using a jQuery .post() AJAX Request to Update Server Data
var params = [{name:"user",value:"Brad"}, {name:"rating", value:"1"}] $.post("setRating.php", params, myHandler);
Using jQuery to post data to the server is easy with the .post()
helper method because .post()
handles all the necessary headers in the background. You call the .post(url, params, handler(data))
method and pass in the url
to the server location, parameter string, or object. Then you specify a handler
to handle the data.
If you pass in an object, it needs to be a list of objects with name
and value
pairs. For example:
var params = [{name:"user",value:"Brad"}, {name:"rating", value:"1"}] ...
Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.