我上面有下一个JavaScript。我需要它来将数据发送到在数据库中插入信息的模型。它的工作人员状况很好,并且记录了信息,但不是将我发送到成功功能,而是将我发送到错误功能。
我正在收到警报(jqxhr):{“ readyState”:0,“ status”:0,“ statusText”:“ error”}
并在console.log(jqxhr)中:{readyState:0,getResponseHeader:ƒ,getAllResponseHeaders:ƒ,setRequestHeader:ƒ,overrideMimeType:ƒ,...…
thrownError在警报和console.log中似乎为空
我不知道代码有什么问题。
function newBenefit(){
var new_professional_id = document.getElementById("new_professional_id").value;
var new_service_code = document.getElementById("new_service_code").value;
var new_service_type = document.getElementById("new_service_type").value;
var new_service_condition = document.getElementById("new_service_condition").value;
var new_price_total = document.getElementById("new_price_total").value;
var new_price_patient = document.getElementById("new_price_patient").value;
var new_date_start = document.getElementById("new_date_start").value;
var new_date_end = document.getElementById("new_date_end").value;
$.ajax({
type: "POST",
url: "index.php?route=professionals/professional_edit_benefit_ajax",
data: {
action: 'new',
professional_id: new_professional_id,
service_code: new_service_code,
service_type_id: new_service_type,
service_condition_id: new_service_condition,
price_total: new_price_total,
price_patient: new_price_patient,
date_start: new_date_start,
date_end: new_date_end,
},
dataType: "json",
fail: function( jqXHR, textStatus, errorThrown ) {
alert(jqXHR);
},
error: function (jqxhr, ajaxOptions, thrownError) {
console.log(jqxhr);
console.log(thrownError);
alert(JSON.stringify(jqxhr));
alert(jqxhr.status);
alert(thrownError);
},
success: function(data){
console.log(data);
if(data=="1"){
//location.reload();
}else{
var continue_text='<?php echo $error_new_benefit_error; ?>';
swal({
type: 'error',
title: 'Oooops...',
text: continue_text,
});
}
}
});
}