这是我的表格
<form id="postProblemForm" action="/Problems/Post" method="post" enctype="multipart/form-data">
<input type="text" id="problemSubject" name="problemSubject" class="inp-form"/>
<input type="file" id="uploadFile" name="uploadFile"/>
<textarea rows="" cols="" class="form-textarea" id="problemDescription" name="problemDescription"></textarea>
<input type="submit" value="Post" id="btnPostProblem" style="width:70px;"/>
</form>
以下是JS
$("#postProblemForm").submit(function (event) {
event.preventDefault();
var $this = $(this);
var url = $this.attr('action');
var dataToSend = $this.serialize();
var callBack = function (isPosted) {
if (isPosted) { alert("posted successfully"); } }
$.get(url,dataToSend,callBack);
});
以下是控制器代码
[HttpPost]
public bool Post(FormCollection form)
{
string subject = form["problemSubject"];
string description = form["problemDescription"];
var image = WebImage.GetImageFromRequest();
return true;
}
但是控制器方法没有被调用。请帮忙。