I have an piece of code here, it's just an ajax options which I use to pass to my $(form).ajaxSubmit(submit_ajax_options)
var submit_ajax_options = {
url: init_param.server_url,
type: 'POST',
data: { agents_data : agents },
dataType: 'json',
timeout: 30000,
beforeSubmit: function( formData, jqForm, options ){
console.log('before submit');
form_loader.fadeIn();
},
success: function( response, status, xhr, $form ){
console.log('success callback');
form_loader.fadeOut();
if(response.status == 'ok'){
create_box('success', response.msg);
setTimeout(function(){
window.location.href = response.redirect;
}, 2000);
}
else{
create_box('danger', response.msg);
}
},
}
And this is my process code on my server (PHP):
<some processing code here>
$response['redirect'] = $redirect_url;
$response['status'] = 'ok';
$response['msg'] = "successfully";
//output data jsone
echo json_encode($response);
when I run as debug on my server, code ran ok without any mistake, but in my js code at client, I don't receive anything callback in my success block of submit_ajax_options (I don't see the logging string in my browser console, although the logging string in beforeSubmit block was printed)
I really have no any idea for this issue. Anybody can help me about my situation. really thank you a lots
You can try this if it helps you
decode your JSON response