Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery .post and form data

I am using .post to post my data to my controller. I would like to pass all the data that I have in a form. Is there an easy way to take all the form data and add it to the .post command to send it?

like image 580
Tony Borf Avatar asked Dec 14 '22 03:12

Tony Borf


1 Answers

use the .serialize method.

var postData = $('#formId').serialize();
$.post(url,  postData);
like image 192
redsquare Avatar answered Dec 27 '22 20:12

redsquare