ajax调用中的formdata

时间:2017-05-20 10:33:15

标签: asp.net ajax asp.net-mvc multipartform-data

当我在json返回后在ajax调用中传递formdata时,它不会返回成功或错误块只是在浏览器上打印值

    String downloadFilepath = "C:\\Utility\\OP_Resources\\MozillaFirefoxDownload";
    System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
    FirefoxProfile Profile = new FirefoxProfile();
    Profile.setPreference("browser.download.dir",downloadFilepath);
    Profile.setPreference("browser.download.folderList",2);
    //neverAsk - saveToDisk - CSV        
    Profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/csv,application/excel,application/vnd.ms-excel,application/vnd.msexcel,text/anytext,text/comma-separated-values,text/csv,text/plain,text/x-csv,application/x-csv,text/x-comma-separated-values,text/tab-separated-values");
    //neverAsk - saveToDisk - ANY       
    Profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/xml,text/plain,text/xml,image/jpeg,application/octet-stream");
    Profile.setPreference("browser.download.manager.showWhenStarting",false);
    //neverAsk - openFile - CSV
    Profile.setPreference("browser.helperApps.neverAsk.openFile","application/csv,application/excel,application/vnd.ms-excel,application/vnd.msexcel,text/anytext,text/comma-separated-values,text/csv,text/plain,text/x-csv,application/x-csv,text/x-comma-separated-values,text/tab-separated-values");
    //neverAsk - openFile - ANY
    Profile.setPreference("browser.helperApps.neverAsk.openFile","application/xml,text/plain,text/xml,image/jpeg,application/octet-stream");
    Profile.setPreference("browser.helperApps.alwaysAsk.force", false);

当我只传递formData时,它可以正常工作

1 个答案:

答案 0 :(得分:-1)

试试这个;

$.ajax({
            url: '@Url.Action("Create", "Inquiry")',
            data: formData,
            datatype: "json",
            type: "POST",

            success: function (data) {
                alert("ssss");
            },
            error: function (msg) {
                alert("error", msg.statusText + ". Press F12 for details");
            }
        });