Php Vue JS HTTP post到API状态代码0重定向到问号
我对自己的API的HTTP post有一些问题 脚本 我在Vue组件中有一个表单构建。该表格用于报价申请 无论帖子何时通过,我都想将webapp重定向到感谢URL。在本地,表单提交良好,并重定向到正确的URL 在服务器上,我得到一个HTTP状态代码0,没有javascript中的状态文本。因此,Php Vue JS HTTP post到API状态代码0重定向到问号,php,laravel,vue.js,vue-resource,Php,Laravel,Vue.js,Vue Resource,我对自己的API的HTTP post有一些问题 脚本 我在Vue组件中有一个表单构建。该表格用于报价申请 无论帖子何时通过,我都想将webapp重定向到感谢URL。在本地,表单提交良好,并重定向到正确的URL 在服务器上,我得到一个HTTP状态代码0,没有javascript中的状态文本。因此,.then()函数被完全忽略。然而,post请求完全通过。在我将JSON返回帖子之前,我正在发送一封电子邮件。这封电子邮件发送得非常好 现在的问题是,可能出了什么问题 我试过的 将.then()更改为.
.then()
函数被完全忽略。然而,post请求完全通过。在我将JSON返回帖子之前,我正在发送一封电子邮件。这封电子邮件发送得非常好
现在的问题是,可能出了什么问题
我试过的
- 将
更改为.then()
.done()
- 只发送电子邮件而不插入整个雄辩的数据库。所有都在本地工作,但不在服务器上工作
submitRequest() {
this.$http.post('/quotation-request', {
products: this.products,
debtor_code: this.debtor_code,
address: this.address,
address2: this.address2,
postalcode: this.postalcode,
city: this.city,
country: this.country,
vat: this.vat,
gender: this.gender,
initials: this.initials,
firstname: this.firstname,
lastname: this.lastname,
email: this.email,
telephone: this.telephone,
companyname: this.companyname,
}).then(request => {
//THIS SHOULD FIRE. BUT WE IGNORE THE THEN FUNCTION.
window.location = '/quotation-request/thanks';
}, (response) => {
console.log(response);
if (response.status == 422) {
this.errors.record(response.body);
bootbox.alert("Er ging iets fout! zijn alle velden ingevuld? <br><br>Klik op de knop 'Edit quotation request' om terug te gaan naar het formulier");
} else {
bootbox.alert("Er ging iets goed fout. Neem contact op met de systeembeheerder !")
}
});
},
submitRequest(){
此.http.post(“/quote request”{
产品:这个产品,,
债务人代码:此为债务人代码,
地址:这个地址,
地址2:this.address2,
postalcode:this.postalcode,
城市:这个城市,
国家:这个国家,
增值税:这个增值税,
性别:这个,性别,
首字母:这个。首字母,
名字:这个,名字,
lastname:this.lastname,
电子邮件:this.email,
电话:这个电话,
公司名称:这个。公司名称,
})。然后(请求=>{
//这应该触发。但是我们忽略THEN函数。
window.location='/报价请求/谢谢';
},(回应)=>{
控制台日志(响应);
如果(response.status==422){
this.errors.record(response.body);
bootbox.alert(“你的报价是多少?
我的报价单编辑请求是多少”);
}否则{
bootbox.alert(“Er INGING iets goed fout.Neem contact op met de SYSTEEMBEEHEERDER!”)
}
});
},
在我的控制台中,代码为0,没有statustext
“网络”选项卡显示:
可能有多种原因导致您获得
状态:0
如403、503,您应该查看Chrome开发工具中的“网络”选项卡,以查看真实的响应状态。问题是我在页面上有两个表单。显示提交发生位置概览的第二个表单没有添加@submit.prevent
属性。cancelled
很可能意味着jQuery正在对活动请求调用abort
,因此您应该查看代码中的并发性。据我所知,我没有看到任何并发性。当时执行的唯一代码就是上面显示的代码!那么只有调试javascript才能帮助您。
submitRequest() {
this.$http.post('/quotation-request', {
products: this.products,
debtor_code: this.debtor_code,
address: this.address,
address2: this.address2,
postalcode: this.postalcode,
city: this.city,
country: this.country,
vat: this.vat,
gender: this.gender,
initials: this.initials,
firstname: this.firstname,
lastname: this.lastname,
email: this.email,
telephone: this.telephone,
companyname: this.companyname,
}).then(request => {
//THIS SHOULD FIRE. BUT WE IGNORE THE THEN FUNCTION.
window.location = '/quotation-request/thanks';
}, (response) => {
console.log(response);
if (response.status == 422) {
this.errors.record(response.body);
bootbox.alert("Er ging iets fout! zijn alle velden ingevuld? <br><br>Klik op de knop 'Edit quotation request' om terug te gaan naar het formulier");
} else {
bootbox.alert("Er ging iets goed fout. Neem contact op met de systeembeheerder !")
}
});
},