如何使用ajax获取php var

I have a html div (with id example) where i want to print php variable $test. My php looks like this:

<?php 

function Test(){
//some action;
return 'Hello World!';
}

$test = Test();
echo $test;

?>

Also i have javascript file :

$.get( "ajax/index.html", function( data ) {
  $( "#example" ).html( data );
});

What's the problem ?

My html file :

...
<script>
function Ajax(){
    $.get( "../Auth/user_save.php", function( data ) {
        $( "#example" ).html( data );});
</script>
<div id = "example"></div>
<input type='submit' onClick='Ajax();'></input>

Your javascript has html link, but you are trying to call php file:

$.get( "ajax/index.html", function( data ) {
  $( "#example" ).html( data );
});

Change it to

$.get( "ajax/your_php_file.php", function( data ) {
  $( "#example" ).html( data );
});