我需要调用codeigniter中的onsubmit函数。 一项用于提交,一项用于访问某个 ID。
我想知道如何在提交时调用两个函数,我还需要知道如果我有真实条件如何通过ajax提交表单。
我的ajax Controller :
$(document).ready(function(){
add = function (){
$.ajax({
type: "POST",
url: ajax_url_store,
data: {action: 'store', views: JSON.stringify(thsirtDesigner.getProduct()) },
success: function(data) {
if(parseInt(data) > 0) {
// i need to submit my form here...
}
},
error: function() {
//alert('some error has occured...');
},
start: function() {
//alert('ajax has been started...');
}
});
}
});
最佳答案
你可以使用jquery:
$("#formId").submit(function(e){
e.preventDefault();
//your code
});
在 JavaScript 中
<form action="" method="post" onsubmit="return yourfunction()">
</function>
function yourfunction()
{
//your code
return true;
}
关于javascript - 如何在codeigniter中调用提交函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24631157/