使用AJAX提交表单

I'm currently learning more about Ajax and PHP and I have come across this problem with my code. It's just a simple form submission using the $.post() method in JQuery but the problem is that when I submit the form locally it will not work but it will work if I place it on a web server.

Can anyone offer any explanation as to why and if there is a way to make this work locally on a web server. I'm currently using MAMP

$('#register').on('submit', function(event){
    event.preventDefault();
    var details = $('#register').serialize();
    $.post('/php/register.php',details,function(data){
        $('#register').html(data);
    });
});