Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从SweetAlert2到PHP获取电子邮件值?_Javascript_Php_Sweetalert2 - Fatal编程技术网

Javascript 从SweetAlert2到PHP获取电子邮件值?

Javascript 从SweetAlert2到PHP获取电子邮件值?,javascript,php,sweetalert2,Javascript,Php,Sweetalert2,您好,在Javscript中实现PHP的最佳方法是什么?输入电子邮件后,我需要做一些编码工作 swal({ type: "success", title: "Congrats!", text: "Please enter your PayPal email address.", input: "email", buttonsStyling: false, heightAuto: false, allowOutsideClick: false, allowEscap

您好,在Javscript中实现PHP的最佳方法是什么?输入电子邮件后,我需要做一些编码工作

swal({
  type: "success",
  title: "Congrats!",
  text: "Please enter your PayPal email address.",
  input: "email",
  buttonsStyling: false,
  heightAuto: false,
  allowOutsideClick: false,
  allowEscapeKey: false
}).then(function (email) {
  swal({
  type: "success",
  text: "You will get your reward within 48 hours.",
  buttonsStyling: false,
  heightAuto: false,
  allowOutsideClick: false,
  allowEscapeKey: false
  })
})

<代码>我想不起作用吧?如何获得输入值以在php中使用它?

php
严格来说是一种服务器端语言,因此它在客户端(JavaScript运行的地方)无法工作

为了在客户端和服务器端之间进行通信,我建议使用AJAX

例如,当用户键入电子邮件并提交时,它可以触发对服务器的ajax请求(php),并执行进一步的操作并获得响应

有很多(我的意思是,很多)关于谷歌如何实现它的教程

我建议您从“将ajax发送到php”开始,然后再开始

根据您拥有的服务器设置,您将能够相当快地找到它

下面是JS中的AJAX调用示例:

 function sample_AJAX(a, b, c) {
    $.ajax({
        type: 'POST',
        url: ajax_url,
        dataType: 'json',
        data: {
            action: a,
            id: b
        },
        success: c
    });
};

祝你好运

一定要接受它作为一个答案,这样其他人也能看到它。谢谢