[英]Refresh page after Ajax call
I have two pages, on the first page you can select an item with a <select> </select>
.我有两页,在第一页上,您可以使用
<select> </select>
选择一个项目。 When you select an item, a form is automatically displayed through an AJAX Call.当您选择一个项目时,将通过 AJAX 调用自动显示一个表单。 In this form, data is automatically loaded from a mysql db in a
<textarea> </textarea>
.在这种形式中,数据自动从
<textarea> </textarea>
的 mysql 数据库加载。 The moment you submit your form, I want the new data to be added to the <textarea> </textarea>
I just can't manage this, who can help me?在您提交表单的那一刻,我希望将新数据添加到
<textarea> </textarea>
我就是无法管理这个,谁能帮帮我?
$(document).ready(function () {
$("#btnAdd").click(function (e) {
/* Retrieving value from textboxes */
var besproken = $('#besproken').val();
$.post("save.php", {
besproken: besproken,
}, function (data) {
$("#autoSave").html("Coaching ");
$("#btnAdd").attr("disabled", true);
});
return false;
});
});
If all you want to do is insert the data into the textarea just use jQuery to selected the element $("textarea")
then call the text method and pass in your data .text(data)
.如果您只想将数据插入 textarea 只需使用 jQuery 选择元素
$("textarea")
然后调用 text 方法并传入您的数据.text(data)
。 The result call will look like $("textarea").text(data)
结果调用看起来像
$("textarea").text(data)
$(document).ready(function() {
$("#btnAdd").click(function(e) {
/* Retrieving value from textboxes */
var besproken = $('#besproken').val();
$.post("save.php", {
besproken: besproken,
}, function(data) {
$("#autoSave").html("Coaching ");
$("#btnAdd").attr("disabled", true);
$("textarea").text(data);
});
return false;
});
});
You can take a div.你可以拿一个div。 When you click submit you will get a ajax response, load this inside the div.
当您单击提交时,您将获得一个 ajax 响应,将其加载到 div 中。
success: function(data){
$("#status").load("url of the php-file");
or
$("#status").html(data);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.