[英]extracting the post parameters from a form using javascript/jQuery before submission
how can i get the parameters of any form being submitted with method=post before it's submitted using javascript(preferably jQuery).在使用 javascript(最好是 jQuery)提交之前,如何获取使用 method=post 提交的任何表单的参数。 What i am trying to do is get the post parameters and submit it to an alternate loacation.
我想要做的是获取帖子参数并将其提交到备用位置。 i was using
我正在使用
$('form').submit(function() {
alert('action= ' + $(this).attr("action"));
alert('serialized string' + $(this).serialize());
return false;
});
but it works only with get request i want to extract the parameters from the post requests too .但它仅适用于获取请求,我也想从发布请求中提取参数。
Something like this works for me像这样的东西对我有用
$('#form').submit(function(){
$.post(your_location, $(this).serialize());
return false;
});
You can use the any other Ajax method you like if you don't want to use $.post().如果您不想使用 $.post(),您可以使用任何其他您喜欢的 Ajax 方法。 You can also include a callback method to handle whatever your ajax call returns.
您还可以包含一个回调方法来处理您的 ajax 调用返回的任何内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.