Ajax调用Keyup函数

我有这种情况:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<form>
<input type="text" id="test" name="test">
</form>
<div id="risultato" style="max-width: 80%;"></div>

Ajax调用Keyup

$(document).ready(function(){
var final = "1";
$("#test").keyup(function(){

$.ajax({
type: "POST",
url: "../templates/g5_helium/html/com_users/registration/ajax.php",
data: "final=" + final,
dataType: "html",
success: function(msg){$("#risultato").html(msg);},
error: function(){alert("Error");}
});
});
});

文件Ajax.php

if ($_POST['final'] == 1) {echo 'Yes';} else {echo 'No';}

但这不起作用..

有任何想法吗? :(

评论