duanbin198788 2010-06-02 23:13
浏览 83
已采纳

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.

  • 写回答

1条回答 默认 最新

  • drx3157 2010-06-02 23:35
    关注

    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"]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题