ajax提交表单问题

下面这个是原生表单提交
image.png
下面是ajax的post请求
image.png
axios的提交结果
image.png
为什么ajax的post请求会报错500?

问题出现的环境背景及自己尝试过哪些方法

在Vue中使用的,jquery的ajax。

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)

this.queryParams.password='c92f37aa72d2fa44a2c25b615b363fdb';        console.log(this.queryParams.password='c92f37aa72d2fa44a2c25b615b363fdb')
       var str =  'username='+this.queryParams.username+'&imageCode='+this.queryParams.imageCode+'&password='+this.queryParams.password;
       console.log(str)
        $.ajax({
             type: "post",
             dataType: "json",
             url: "/api/authentication/form" ,
             data: str,
             success: function (data) {
                 console.log(data)
             },
             error : function() {
                 alert("异常!");
             }
         });
this.$axios.post('/api/authentication/form',
         str
     )
     .then((response) => {
         console.log("提交成功!, 刚才提交的内容是:" + response)
       },
       (response) => {
         alert("出错了")
       }
     ) 

你期待的结果是什么?实际看到的错误信息又是什么?

报错
实在开不出来JQuery的ajax为什么会报错
image.png

阅读 1.7k
1 个回答

5XX 这特么是后端问题啊!

这要是后端写的代码压根不支持 X-Requested-With 你搁前端找一辈子也找不到原因。


@Infogami
image.png

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进