Textarea使用jQuery / MySQL刷新
OK so let's say I have a textarea on the top of my browser and a text input box on the bottom. I want to connect a MySQL database and also whatever I type in the input box to appear in the text area. Sorta like a text RPG...
I know PHP, MySQL, good AJAX, and little jQuery. I just want to know how this is achieved. Thank you.
好的,假设我的浏览器顶部有一个textarea,底部有一个文本输入框。 我想连接一个MySQL数据库,以及我输入框中输入的任何内容,以显示在文本区域中。 Sorta就像文本RPG ... p>
我知道PHP,MySQL,优秀的AJAX和小jQuery。 我只是想知道这是如何实现的。 谢谢。 p> div>
You can do something like this (the code below sends input text to php script which connects to database, does whatever you want it to do and prints a text to be displayed in text area) :
$("#update_btn").click(function() {
var txt = $.ajax({
url: 'your_file.php',
async: true, // or false, depends on your needs
type:'POST',
data:({new_text:$('#input_box_1').val()})
}).responseText;
$('#txt_area_1').val(txt);
});
To access new_text
variable in php script, use $new_text = $_POST["new_text"]