J-query Ajax call returns 0 in error function. Usually 0 error is returned when there is no internet connection. Even though my Internet connection is perfectly fine. The problem is it works fine on friend's machine. And on friend's machine, if I turn wifi off, after loading page , as it should work it do return no internet connection on his machine.
$(document).ready(function(){
$("#forget_form").submit(function(event){
event.preventDefault();
$('#result').html('Processing...');
$.ajax({
url: '<?php echo base_url(); ?>Index/forget',
type:'POST',
data: {
email: $("#email").val(),
},
success:function(data){
$('#result').html(data)
},
error: function (jqXHR, exception) {
var msg = '';
if (jqXHR.status === 0) {
msg = 'There is no Internet connection.';
} else if (jqXHR.status == 404) {
msg = 'Requested page not found. [404]';
} else if (jqXHR.status == 500) {
msg = 'Internal Server Error Occured. [500].';
} else if (exception === 'parsererror') {
msg = 'Requested JSON parse failed.';
} else if (exception === 'timeout') {
msg = 'Request Time out reached.';
} else if (exception === 'abort') {
msg = 'Ajax request aborted.';
} else {
msg = 'Uncaught Error.
' + jqXHR.responseText;
}
$('#result').html(msg);
},
});
});});