I\'m having a very hard time trying to do something very simple. Here\'s the code:
if(data == \'success\') {
alert(\'foo\');
}
You can fix it on the client side using $.trim() like this:
if($.trim(data) == 'success') {
Or, a better approach would be removing the new-line coming from the server-side, probably an erroneous new-line in your PHP somewhere, check before or after the ?>
block, this is most often where they crop up.
Or, just exit after outputting your content, like this:
if($update) {
echo 'success';
exit();
}