Can someone please guide me through where am I going wrong in this piece of code below
index.php :-
<script type="text/javascript">
function fun(){
    alert("H");
    $.ajax({
    type: "POST",
    url: 'test.php',
    data: {name: 'Wayne', age: 27},
    success: function(data){
        alert(data);
    },
    error: function(error){
        alert(error);
    }
});
    alert("HE");
    }
    </script>
    <input type="button" value="submit" onclick="fun()" /> 
test.php :-
<?php
    $name = $_POST['name'];
    $age = $_POST['age'];
    echo $name.$age;
?>
I'm not getting any output nor any error.
 
    