Way To Pass Every Field In A Form Into The Ajax Requet
Is there a nice way to loop through a form and collect all textboxes, selects, textareas, and checkboxes and pass their values into the ajax request params? For example:
-
$.ajax(
{
url: 'my_server_side_code.php',
// Get all textfields, selects, textareas, checkboxes and pass into the data property.
data: {},
timeout: 5000,
cache: false,
type: 'post',
dataType: ''text",
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("Oops! " + errorThrown);
},
success: null
});