I use AJAX all the time and never have a problem. All of a sudden every one of my AJAX calls to a variety of server side PHP pages is returning a 200 error. When I visit the PHP page get_message_list.php
directly it is perfectly echoing a JSON encoded array as expected {"msg_count":2}
, so I know that is correct. If I change the dataType to “text” to test it just outputs the current page HTML. This just started happening and I have no idea what Im doing wrong?!
$.ajax({
type:'POST',
url: 'functions/get_message_list.php',
data:{"test":1},
contentType: 'application/json;charset=UTF-8',
dataType : "json",
success:function(data){
alert(data.msg_count);
},error: function (request, status, error) {
alert(request.status);
}
})
On the page I output echo json_encode(array("msg_count"=>$mail_list_rows));
which as I said is working fine.