How do you know your script isn't receiving the data?
change success to the following:
success: function(data){
$("#result").html('Submitted successfully:' + data);
},
All you are doing is saying 'if a response is received without an error update a div' - you have no way of knowing if your php script has run SUCCESSFULLY (it has run as you are getting success) or not at the moment.
with the 'data' in the function you can then see if information has been passed back by your script.
Try the above and let us know how you get on
FOR CLARITY
PHP scripts when you access them are run ONCE - they have no memory (other than fixed variables such as $cheese = "yummy";
The reason you cannot see a response when you access the page (even after running your script) is that it is a bit stupid and doesn't remember you ran it.
So accessing the script directly the script is going
'Oh - it's show time, right.....err.....ok - has the person sent me 'bar' - nope well in that case I will not do what is inside the if statement - end of my job - nothing to do here I will send nothing back.'
Try this:
change $_POST['bar'] to $_GET['bar'];
Then go to your URL where the script is and type http://yoururl.com/script.php?bar=terrence
You will notice you now get a response because you passed the script what it wanted to return true and so do what is inside the if statement.
For data to persist you need to store to a database or a text file.
Hope that is clear!