通过jQuery和Ajax从用户输入更新textarea

我正在尝试更新我的php文件中的值,并使用jquery和ajax将其显示在textarea中。 为了缩短它,我有:
1-带有用户输入和提交按钮的表单和文本区域
2-一个名为data.php的PHP文件
3 – 和html文件
这是我的代码


PHP就像这样简单:

 <?php $name = "Jordano"; echo $name; 

这是jquery

 $(document).ready(function() { $('#txta-update').click(function() { $.ajax({ type: "GET", url: "data.php",//get response from this file success: function(response){ $("textarea#wstxt").val(response);//send response to textarea } }); }); }); 

你能告诉我如何将输入值发送到php并从新值更新textarea吗? 谢谢

更新 在此处输入图像描述

像这样发送数据

 data:{name:$('input[name="name"]').val()} 

你js文件变成了

  $.ajax({ type: "GET", url: "data.php", //get response from this file data:{name:$('input[name="name"]').val()}, success: function (response) { $("textarea#wstxt").val(response); //send response to textarea } }); 

要么

 $(document).ready(function () { $('#txta-update').click(function () { var name_val = $('input[name="name"]').val(); $.ajax({ type: "GET", url: "data.php", //get response from this file data: { name: name_val }, success: function (response) { $("textarea#wstxt").val(response); //send response to textarea } }); }); }); 

为了获得PHP的价值