Jquery没有将数据传输到Controller

时间:2017-10-19 20:58:42

标签: javascript c# jquery asp.net-mvc

我遇到一个问题,当我调用一个函数来传输数据文件和参数时。 alert()显示数据,但它没有传输到控制器。显示空值的控制器

Jquery

 $(".UpdateClientInfomationOutCome").click(function () {
        debugger;
        alert("Test");



        var formData = new FormData($("#fileupload")[0]);
        var collectFacilityNam = $("#Collect_Facility_Name").val();
        var locationProviderNam = $("#Location_Provider_Name").val();
        var locationProviderAddres = $("#Location_Provider_Address").val();

        $.ajax({
            url: '@Url.Action("ClientInformatioUpdate", "OutCome")',
            type: 'POST',
            data: { doc: formData, collectFacilityName: collectFacilityNam, locationProviderName: locationProviderNam, locationProviderAddress: locationProviderAddres },
            cache: false,
            contentType: false,
            processData: false,
            async: false,
            success: function (data) {

            }
        });

    });

控制器

[HttpPost]
    public ActionResult ClientInformatioUpdate(FormCollection collection,string collectFacilityName, string locationProviderName, string locationProviderAddress, HttpPostedFileBase doc)
    {

        return View();
    }

HTML

<form method="post" enctype="multipart/form-data">
    <div class="container" style="width: 90%">
        <fieldset>
            <legend style="font-size: large; text-align: center"> Add Client Information</legend>
            <input class="text-box single-line" id="Collect_Facility_Name" name="Collect_Facility_Name" type="text" value="" placeholder="Collect Facility Name">
            <input class="text-box single-line" id="Location_Provider_Name" name="Location_Provider_Name" type="text" value="" placeholder="Location Provider Name">
            <input class="text-box single-line" id="Location_Provider_Address" name="Location_Provider_Address" type="text" value="" placeholder="Location Provider Address">
            <input style="display: none" name="AlreadyinCare" type="text" value="AlreadyinCare">
            <input type="file" name="doc" id="fileupload" multiple="" placeholder="Upload Document">
           <br>
            <input name="file" type="text">
        </fieldset>

        <input type="hidden" name="form_type" value="NeverinCare">
        <div style="float: right;">

            <input type="button" class="UpdateClientInfomationOutCome" value="Add">



        </div>
</form>

0 个答案:

没有答案