sending full form data to back end using jquery
i have a form that is dynamically built. so the number of form elements arr not fixed. I wnat to send whole of $_POSt data from the form using jquery to back end for processing .i cant use jquery form plugin as the jquery version i am using is old.
any other way ? i tied to do like this
$.post('all_include_files/updat开发者_JAVA技巧e_save.php',{variable:"<?php echo json_encode($_POST) ?>"},function(data)
{
alert(data);
})
but did not work
Take a look at jQuery.serialize().
It looks like what you're trying to accomplish is similar to:
$.ajax({
type: 'POST',
url: 'all_include_files/update_save.php',
data: $("form").serialize(),
success: function(result){ alert(result); }
});
Use .serialize()
(was added in jQuery 1.0)
The
.serialize()
method creates a text string in standard URL-encoded notation. It operates on a jQuery object representing a set of form elements.
E.g.
var data = $('#formid').serialize()
精彩评论