ajax - Ajax 调用在 Firefox 和 safari 中失败,但在 chrome 中运行良好
问题描述
我正在尝试使用 ajax 调用执行一个操作,在 chrome 中一切正常,但是当我在 firefox 或 safari 浏览器中执行相同的操作时,它会抛出错误的请求。我可以在网络选项卡中看到对 url 进行了调用,但未提供任何状态,然后使用 laravel 错误“MethodNotAllowedHTTPException”回调引用页面。我也在添加我的代码。
function transactionAction(value, id, amount){
//event.preventDefault();
document.getElementById("formSubmitButton").disabled = true;
var SITE_URL = "{{url('')}}" + ('/web/v1/dispute-refund');
var actionId = value;
var pId = id;
$.ajax({
type: 'POST',
url:SITE_URL,
headers: {
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
},
contentType: "application/json; charset=utf-8",
dataType: "json",
data:{
actionId:actionId,
pId:pId,
amount:amount,
"_token": "{{ csrf_token() }}"
},
success: function (response){
$('.refund').modal('hide');
if(response.result.status == true){
$('.error-divbox-master').html('<div class="alert alert-success alert-dismissible"><h4><i class="icon fa fa-check"></i>'+response.result.message+'</h4></div>').delay(10000).show().fadeOut('slow');
document.getElementById("formSubmitButton").disabled = false;
}else{
$('.error-divbox-master').html('<div class="alert alert-danger alert-dismissible"><h4><i class="icon fa fa-check"></i>'+response.result.message+'</h4></div>').delay(10000).show().fadeOut('slow');
document.getElementById("formSubmitButton").disabled = false;
}
setInterval(function(){location.reload();},3000);
},
error: function (response) {
$('.refund').modal('hide');
$('.error-divbox-master').html('<div class="alert alert-danger alert-dismissible"><h4><i class="icon fa fa-check"></i>'+response.result.message+'</h4></div>').delay(10000).show().fadeOut('slow');
document.getElementById("formSubmitButton").disabled = false;
}
});
}
解决方案
尝试方法:“POST”而不是 类型:“POST”
推荐阅读
- python - Blender 2.8 错误消息:“NoneType”对象在更改“抽取”值时没有属性“修饰符”
- linux - 为什么命令行的第一行不作为输出
- javascript - Math.floor 不适用于 cartian 测试用例
- swift - 在 Swift 的递归函数中调用重载函数
- python - Flask 视频代理流不允许浏览时间栏
- azure - 找不到事件中心资源
- python - 如何转发填充熊猫中缺少的列,这样就不会丢失日期
- sas - 用其他矩阵的值制作新矩阵
- sas - 如何在 SAS 中使用用户定义的函数
- javascript - 地球引擎:在 ee.ImageCollection 上映射会返回 ee.FeatureCollection