php ajax连接失败

Using the following I have tried a hundred different ways and all I get is the failure alert Please could anyone spot my silly beginners mistake

myy.php

$con = mysqli_connect('adress','dbase','pass','table');
$result = mysqli_query("SELECT mycoat FROM $table");          
$response  = array();
while($array = mysqli_fetch_row($result)) {
    $response[] = $array;
}

echo json_encode($response);

JavaScript:

function myfunction()
{
    $.ajax({
        url: 'myy.php',
        dataType: 'json',
        success: function() {
            alert('success');
        },
        error: function() {
            alert('failure');
        }
    });
}

Try this, You have missed db connection link in mysqli_query

  $result = mysqli_query($con, "SELECT mycoat FROM $table");        

instead of,

 $result = mysqli_query("SELECT mycoat FROM $table");