在一个巨大的网络应用程序中,我需要一个提交表单的解决方法。
为了覆盖内置的 javscript 方法,我尝试了这个示例,但我什至没有收到警报弹出窗口。
我对覆盖提交功能的想法是这样的:
function submit(event) {
var target = event ? event.target : this;
$.ajax({
url: target.action,
data: $('form').serialize(), // &nd someone knows how I can get the serialize() of the form I just clicked?
success: function (data) {
alert('done');
},
error: function (data) {
alert('error (check console log)');
console.log(data);
}
});
//this._submit();
return false;
}
到处使用提交的方式并不一致。原始代码中的可能性:
<button onclick="form.submit">
onclick="calltoFunction();" // where inside the function the submit is called
<button type="submit" // the normal way
我想我的想法是可能的,因为我之前覆盖了 js-functions。但是我应该如何处理提交部分。欢迎任何建议,想法,修复!