$('').form('submit',{url: , onSubmit: ,success: )
还想麻烦您个问题,我现在还想调用上面这个局部表单提交的函数实现excel文件导入并在datagrid显示的功能。
通过点击上传文件,按下“导入”按钮,调用script中的excel_process()函数实现表单提交,读取和返回数据,最后再刷新datagrid。
但是这样做按下按钮,没有实现表单的提交功能。
<div>
<form name="import" id="import2" method="post" enctype="multipart/form-data"><p>打开文件:<input type="file" name="file" id="select"/></p>
<p><button id="but" οnclick="excel_process()" >导入</button> </p>
</form>
function excel_process(){
$('#import').form('submit',{
url: 'excelprocess.php',
onSubmit: function(){
},
success: function(result){
var result = eval('('+result+')');
if (result.success){
$('#dg').datagrid('reload'); // reload the user data
} else {
$.messager.show({
title: 'Error',
msg: "import excel errors!"
});
}
}
});
}
<div class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
buttons="#dlg-buttons">
<form id="import" method="post" novalidate enctype="multipart/form-data">
<input type="file" name="file" id="file"/>
</form>
</div>
<div id="dlg-buttons">
<a href="#" class="easyui-linkbutton" iconCls="icon-ok" οnclick="excel_process();">Save</a>
</div>
请教下有没有解决的方法? 如何能够通过自己定义的form 和 button实现局部表单的提交?