Something to try here is to change $.post for $.ajax so that you can specify an error callback. $.get , $.post , etc. - these are just transcripts for $.ajax . Try something like this:
("button").click(function() { var msg = $("#txt").val(); $.ajax( url: "http://localhost/bot.php", data: {msg: msg}, dataType: 'jsonp', success: function(data,status) { console.log(data, "returned with status:", status); }, error: function(obj, status, error){ console.log("Error!", obj, status, error); } ); });
Just because you get a 200 response does not mean that everything is working correctly. All this suggests that POST was successful. You need to check the response text to see if any errors are returned.
EDIT: added to dataType: 'jsonp' for the request.
source share