Javascript 在内部输入新文本后更新textarea内容的值

Javascript 在内部输入新文本后更新textarea内容的值,javascript,jquery,html,Javascript,Jquery,Html,我想在页面中添加一个文本区,在该文本区内键入新文本并将其保存在服务器上(不仅仅是cookies)。 页面将以不同的上下文重复多次,例如名称和其他内容。我想在每页上分别更改textarea,而不是在每页上覆盖它 到目前为止我的手机区号: <div id="descriptionDiv" style="float:right;"> <form id="addDescription-form"> <fieldset>

我想在页面中添加一个文本区,在该文本区内键入新文本并将其保存在服务器上(不仅仅是cookies)。 页面将以不同的上下文重复多次,例如名称和其他内容。我想在每页上分别更改textarea,而不是在每页上覆盖它

到目前为止我的手机区号:

    <div id="descriptionDiv" style="float:right;">
       <form id="addDescription-form">
         <fieldset>
            <input type="textarea" id="descriptionTextboxID" name="descriptionTextbox" style="width:400px;height:75px" class="text ui-widget-content ui-corner-right" placeholder="Short description" ></input></p>
            <button type="submit" value="Submit" onClick="addText()">Save</button>
       </fieldset>
   </form>
</div>

每一页上都会有唯一的名字。我可以用它来区分文本区域上下文吗?到目前为止,我在服务器上保存新值时也遇到了问题,当我刷新页面时,我再次看到一个占位符,而不是一个新值

如果你花两个小时看完这个(免费)视频系列,你将成为一名职业选手

对于从文本区域读取:

var ta_content = $('#myTA').val();
要更新服务器,请执行以下操作:

$.ajax({
    type: 'post',
     url: 'your_php_processor_file.php',
    data: 'ta=' + ta_content,
    success: function(d){
        //anything the server echoes back will be in var " d ". So, for e.g.:
        if (d.length) alert(d);
    }
});
您的\u php\u处理器\u文件。php:

<?php
    $tarea = $_POST['ta'];

    //do your mysqli_ input here, using $tarea variable

    echo 'This goes back to the AJAX block';

感谢@gibberish提供您的答案和链接。我忘了补充一个问题,我想更新textarea的页面正在使用scala模板,我不确定我是否应该/可以这样做。
<?php
    $tarea = $_POST['ta'];

    //do your mysqli_ input here, using $tarea variable

    echo 'This goes back to the AJAX block';
$('#addDescription-form').submit(function(e){
    var ta_content = $('#myTA').val();

    $.ajax({
        type: 'post',
         url: 'your_php_processor_file.php',
        data: 'ta=' + ta_content,
        success: function(d){
            //anything the server echoes back will be in var " d ". So, for e.g.:
            if (d.length) alert(d);
        }
    });

    //THIS PART:
    e.preventDefault();
});