dqh19413 2013-06-19 10:18
浏览 56
已采纳

调用函数后,Ajax数据进入文本框

I have been looking at a few samples of ajax and realise that most of them will echo back the result. I have a few questions on jQuery/ajax

Is echo-ing the only it can return a data after the function processes it? Will it be possible for me to eg GRAB data from Textbox 1 2 3 and process it on process.php then pass the variable back via ajax and update the textbox's values?

Would be great if you have any samples on Grabbing data from textbox , pushing it to another php file and returning the variable to the actual form's textbox.

Thank you!

  • 写回答

2条回答 默认 最新

  • doudizhi947129 2013-06-19 10:23
    关注

    You may start with the following code:

    $.ajax({
        type: "GET", //May try POST too
        url: "somefile.php",
        data: $("#txtBox").val(),
        dataType: 'text', 
        success: function(data) {
            $("#txtBox").val(data);
        },
        complete: function() {
            alert('Complete: Do something.');
        },
        error: function() {
            alert('Error: Do something.');
        }
    });​
    

    Please use this as a starting point and not as a copy-paste solution.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作