I am having a problem with a simple callback function in jQuery ajax. Google won't help and stack overflow wouldn't either, so I guess this might not be something specific but rather something I am too ignorant to see. To me the code looks exactly like it should.
So, here's the code:
function sendMessage(message)
{
//Establish connection to php script
$.ajax({
type: 'POST',
url: 'action/chat/test.php',
success: function(feedback){
alert(feedback);
}
}).error(function(){
//Do some error handling here
});
}
In test.php it simply says
<?php
echo "called";
?>
As far as I am concerned "called" should be alerted - but it isn't. I have checked already that the function sendMessage() is called (and the parameter message doesn't matter for now).
Does anyone have any idea?
sendMessage()
, does it show? – Pruneerror
, rather thansuccess
, callback function is executed. Using your browsers debugger would be a good first step. – Luteousaction/chat/test.php
in your browser? Do you server logs show that file being hit when you run the AJAX? – Barreto