duankui6150 2013-02-02 05:10
浏览 28
已采纳

“ajax()调用将地址传递到数据库”?

I am trying to create a email invite form where the user inputs their friend's email address and an email is sent to that friend with further instructions on how to sign up for the website.

My question is this: how do I use AJAX to store the email address that the user submits to mySQL database?

Here is the snippet of code that the author of the email invite form demo said to use "ajax() call to pass the address into your database":

function completeInviteForm() {
setTimeout(function() {
    $("#completeform").fadeOut(400, function(){
        $(this).before('<span class="msg">All set! We will be in touch.</span>');
    });
}, 1100);

}

  • 写回答

1条回答 默认 最新

  • dongyukui8330 2013-02-02 05:15
    关注

    You can not use AJAX to store the email in the database but what you can do is pass the email address from the client-side to server-side. Then at the PHP level you can store the email address in the database.

    AJAX Call

    var email = 'example@example.com'
    $.ajax({
      url: "database.php",
      mail: email
    }).done(function() {
      alert("done");
    });
    

    PHP - database.php

    $mail = $_REQUEST['mail'];
    echo $mail; // "example@example.com"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog