什么是javascript中'formdata'的替代品? [英] whats the alternative to 'formdata' in javascript?

查看:673
本文介绍了什么是javascript中'formdata'的替代品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过使用IE9中不支持的'formdata'在MVC中发布文件。请建议任何替代方案。

代码:



i am trying to post file in MVC by use of 'formdata' which is not supported in IE9. please suggest any alternative to this.
Code:

var formData = new FormData($('#profileForm')[0]);
           if (actionName == "Save") {

               $.ajax({
                   url: '@Url.Action("AddProfile", "ProductProfile")',
                   type: "POST",
                   dataType: 'text',
                   contentType: false,
                   processData: false,
                   cache: false,
                   data: formData,
                   success: function (response) {
                       if (response != "Success") {
                           $('#errreportname').text(response);
                           setTimeout(function () { $('#errreportname').text(''); }, 3000);

                       }
                       else {
                           $('#closebtn').click();
                           GetListOfProfile();
                           clear();
                       }
                   },
                   error: function () {
                       $('#error').text("Unable to create the record");
                       setTimeout(function () { $('#error').text(''); }, 3000);
                   }
               });
           }

推荐答案

('#profileForm')[0]);
if(actionName ==Save){
('#profileForm')[0]); if (actionName == "Save") {


.ajax({
url:'@ Url.Action(AddProfile,ProductProfile)' ,
类型:POST,
dataType:'text',
contentType:false,
processData:false,
cache:false,
data :formData,
success:function(response){
if(response!=Success){
.ajax({ url: '@Url.Action("AddProfile", "ProductProfile")', type: "POST", dataType: 'text', contentType: false, processData: false, cache: false, data: formData, success: function (response) { if (response != "Success") {


('#errreportname')。text(response) ;
setTimeout(function(){
('#errreportname').text(response); setTimeout(function () {


这篇关于什么是javascript中'formdata'的替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆