Question on $.post() and $.get() callback function

They should both work. So long as some.php returns a success code (200), the success handler will be called (the real question should be why does the first one work).

The only way I was able to get the first to work, and second to fail was to call a non existent php file (status 404).

Clearly some.php is not returning 200, it's returning an error code, mostly likely not found (404). You can check the status code by opening the console and going to the Network tab, and then clicking your sendMessageBtn.

You are right, they should both work. The reason the closure didn't work before was because of a stupid mistake on my side. I put some comment //this script is ... before <?php, which somehow messed up the script.
 
Back
Top