Jquery表单提交不起作用
我的代码可能有什么问题?我错过什么了吗?Jquery表单提交不起作用,jquery,asp.net-mvc,Jquery,Asp.net Mvc,我的代码可能有什么问题?我错过什么了吗? 对于记录,如果我删除evt.preventDefault();一切正常,但我需要防止在没有ajax的情况下提交表单。更改此选项 POST http://localhost:3043/Transport/GridUpload 500 (Internal Server Error) 你不能同时使用sumit和Ajax“一切正常,但我需要防止在没有Ajax的情况下提交表单。”-这意味着我只需要Ajax提交。。。?所以我应该更改$('#fileUpload'
对于记录,如果我删除evt.preventDefault();一切正常,但我需要防止在没有ajax的情况下提交表单。更改此选项
POST http://localhost:3043/Transport/GridUpload 500 (Internal Server Error)
你不能同时使用sumit和Ajax“一切正常,但我需要防止在没有Ajax的情况下提交表单。”-这意味着我只需要Ajax提交。。。?所以我应该更改$('#fileUpload')。提交给什么?我在你的代码中看到你正在通过表单上传一些数据。所以这里需要提交。Ajax无法工作。问题是
$(“#fileUpload”).serialize()返回空字符串,因为。要了解如何通过Ajax将文件发送到服务器,请查看在asp.net mvc中异步签出上载图像,然后了解上载代码如何工作?由于其上载数据enctype=“multipart/form data”仅适用于提交的表单。这对我来说是行不通的Ajax@AmitAgrawalmisclick.还需要在中提供参数名称data@JustinaSeliokaite你必须用表单提交自己。Ajax帖子在这里没有帮助,因为您正在上传一些数据。
@using (Html.BeginForm("GridUpload", "Transport", new { tipas = 1 }, FormMethod.Post, new {enctype="multipart/form-data", id = "fileUpload" }))
{
<table style="margin-top:0px;">
<tr>
<td>
<label for="file">Filename:</label>
</td>
<td>
<input type="file" name="file" id="file" />
</td>
<td>
<input type="submit" class="upload-button" value="Upload" />
</td>
</tr>
</table>
}
POST http://localhost:3043/Transport/GridUpload 500 (Internal Server Error)
<input type="button" id="fileUpload" class="upload-button" value="Upload" />
$('#fileUpload').click(function (evt) {
@using (Html.BeginForm("GridUpload", "Transport", new { tipas = 1 },
FormMethod.Post, new {enctype="multipart/form-data", id = "fileUpload1" }))