Answer the question
In order to leave comments, you need to log in
Why does Ajax return an error even if the status is 200?
answers[1] = {
"answid": 12,
"ans_val": 4325,
"quest_id": 54,
}
answers[2] = {
"answid": 13,
"ans_val": 43151,
"quest_id": 64,
}
$.ajax({
url: "/Results.php",
type: "POST",
data: {answers: JSON.stringify(answers)},
dataType: 'json',
success: function (results) {
$.each(results, function (key, val) {
if (val.res == "good") {
alert("Success");
}else if(val.res =="bad"){
alert("Fail");
}
}
},
error: function (err){
console.log(err);
}
});
if($this->SqlError==null){
return [
"data"=>[
'res' => "good",
'all_answers' => 3,
'sub' => 3,
],
];
}else{
return [
"error"=>$this->SqlError["error"],
];
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question