我的ajax调用有问题。当我尝试从我的 PHP 发出请求时,ajax 在错误函数中返回,我不知道为什么,因为一切正常。我的 PHP 中的所有数据都正确插入,我在我的 PHP 中返回了类似的内容:echo json_encode($response);当我检查浏览器网络然后导航我的 ajax 请求时,它给了我成功,但在我的 ajax 回调成功函数中,它没有而是执行它会出错。
这是我的ajax请求:
let fileInput = $('#file_input')[0];
let postData = new FormData();
$.each(fileInput.files, function(k,file){
postData.append('requirement_files[]', file);
});
let other_data = $('#new_foster_applicant_frm_id').serializeArray();
$.each(other_data,function(key,input){
postData.append(input.name,input.value);
});
$.ajax({
url : baseurl+'user/post/new_foster_applicant',
type : 'POST',
data : postData,
contentType: false,
processData: false,
success : function(response) {
if(response.success === 'true') {
console.log('true');
// $('.returen_savs').html('Please copy the transaction code serve as your transaction receipt...');
// $('.error_hadble').html('<div class="alert alert-success fade in m-b-15">'+'Transaction Code:'+response.transaction_code+'</div>');
}else {
console.log('false');
// $('.returen_savs').html('');
// $('.error_hadble').html('<div class="alert alert-danger fade in m-b-15">'+'Error in submitting. Please try again later'+'</div>');
}
},
error : function(e) {
console.log(e);
}
});
