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

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

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程