美文网首页
AngularJS $http 表单提交

AngularJS $http 表单提交

作者: 一个爱写文章的技术宅 | 来源:发表于2019-01-21 15:55 被阅读9次

    背景

    项目中文件和图片上传,后端要求用表单提交。

    踩坑过程

    一开始没有在官方文档上找到方法,使用了jquery的ajax来做表单提交。后面发现会出现一系列的问题,比如AngularJS的拦截器无法针对ajax进行处理。

    解决方法

    经过一番实践。发现了写法

    return $http({
            method: 'POST',
            url: url + "organizations/" + _this.getOrgCode() + "/import",
            data: formData,
            headers:{ 'Content-Type': undefined }
    });
    

    相关文章

      网友评论

          本文标题:AngularJS $http 表单提交

          本文链接:https://www.haomeiwen.com/subject/nybcjqtx.html