weixin_33681778 2018-12-17 18:51 采纳率: 0%
浏览 27

Ajax请求关闭MVC表单

I am trying to do an ajax request and depending on the ajax request results I will allow the form to submit to the controller. However everytime the ajax request runs I get the error message.

Here is my javascript function:

function CheckForValidation(e) {
    var scholarshipRequest = $("#scholars").val();
    var aidYearRequest = $("#aidYear").val();
    var amountRequest = $("#amount").val();

    $.ajax({
        type: "POST",
        url: '@Url.Action("Validate_ScholarshipRequest", "RequestController")',
        data: {
            scholarshipId: scholarshipRequest,
            aidYear: aidYearRequest, 
            amount: amountRequest
        }
    }).success(function(response) {
        if (!response.success) {
            e.preventDefault();
            alert(success);
        } else {
            e.preventDefault();
        }
    }).error(function() {
        e.preventDefault();
        alert("Error on Submission");
    });
}

This function is called from here:

$("#SubmitTutorRequestFrm").submit(function(e) {
    e.PreventDefault();
    CheckForValidation(e);
});

I try to debug the code and put a breakpoint on Validate_ScholarshipRequest but that method never gets called. The method signature is:

public ActionResult Validate_ScholarshipRequest(string scholarshipId, string aidYear, string amount)

This is the start of my form:

@using (Html.BeginForm("SubmitScholarshipRequest", "Request", FormMethod.Post, new { id = "SubmitTutorRequestFrm" }))
  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 Android URL如何转成视频/音频,可行吗?
      • ¥20 SQL数据查询,子查询
      • ¥15 c++字符串分割问题
      • ¥15 关于#sql#的问题:没有用命令关闭cdc,手动把系统表开启的cdc右键删除了
      • ¥15 vue+uniapp
      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题