Can you help explain the callbacks on $.get and $.post.
The some.php here is a script that returns some json. I don't understand why the former gets called and latter doesn't get called, all else equal.
Fkc, I just realised I included some invisible comments before <?php
The some.php here is a script that returns some json. I don't understand why the former gets called and latter doesn't get called, all else equal.
Code:
$( "#sendMessageBtn" ).click( function(event) {
event.preventDefault();
var message = $("#chatMessage").val();
$.post("some.php", {'message': message}, alert("I am back") );
});
Code:
$( "#sendMessageBtn" ).click( function(event) {
event.preventDefault();
var message = $("#chatMessage").val();
$.post("some.php", {'message': message}, function(){alert("I am back");} );
});
Fkc, I just realised I included some invisible comments before <?php
Last edited: