<tfoot id='4bzn9'></tfoot>

      1. <i id='4bzn9'><tr id='4bzn9'><dt id='4bzn9'><q id='4bzn9'><span id='4bzn9'><b id='4bzn9'><form id='4bzn9'><ins id='4bzn9'></ins><ul id='4bzn9'></ul><sub id='4bzn9'></sub></form><legend id='4bzn9'></legend><bdo id='4bzn9'><pre id='4bzn9'><center id='4bzn9'></center></pre></bdo></b><th id='4bzn9'></th></span></q></dt></tr></i><div id='4bzn9'><tfoot id='4bzn9'></tfoot><dl id='4bzn9'><fieldset id='4bzn9'></fieldset></dl></div>
      2. <legend id='4bzn9'><style id='4bzn9'><dir id='4bzn9'><q id='4bzn9'></q></dir></style></legend>
        • <bdo id='4bzn9'></bdo><ul id='4bzn9'></ul>

        <small id='4bzn9'></small><noframes id='4bzn9'>

      3. 如何在 html 按钮单击时调用 php 脚本/函数

        How to call a php script/function on a html button click(如何在 html 按钮单击时调用 php 脚本/函数)
              <bdo id='MDz4l'></bdo><ul id='MDz4l'></ul>
              <tfoot id='MDz4l'></tfoot>
            • <legend id='MDz4l'><style id='MDz4l'><dir id='MDz4l'><q id='MDz4l'></q></dir></style></legend>
              <i id='MDz4l'><tr id='MDz4l'><dt id='MDz4l'><q id='MDz4l'><span id='MDz4l'><b id='MDz4l'><form id='MDz4l'><ins id='MDz4l'></ins><ul id='MDz4l'></ul><sub id='MDz4l'></sub></form><legend id='MDz4l'></legend><bdo id='MDz4l'><pre id='MDz4l'><center id='MDz4l'></center></pre></bdo></b><th id='MDz4l'></th></span></q></dt></tr></i><div id='MDz4l'><tfoot id='MDz4l'></tfoot><dl id='MDz4l'><fieldset id='MDz4l'></fieldset></dl></div>

                    <tbody id='MDz4l'></tbody>

                  <small id='MDz4l'></small><noframes id='MDz4l'>

                1. 本文介绍了如何在 html 按钮单击时调用 php 脚本/函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在有人攻击我或将其标记下来之前,我已经查看了整个互联网以了解如何执行此操作(包括 stackoverflow 上的相同问题).我是新手,我发现学习新概念非常困难,所以请放轻松.

                  Before someone has a go at me or marks this down, I have looked all over the internet to find out how to do this (including the same question on stackoverflow). I'm new, and I am finding it very hard to learn new concepts so please be easy on me.

                  我想要做的是在单击按钮时调用 php 脚本/函数.如果有帮助,我会在 WAMP 中运行它.这是我的代码:

                  What I want to do is call a php script/function on a button click. I have this running in WAMP if that helps. Here's my code:

                  <?php include 'the_script.php'; ?>
                  
                  <button type="button" onclick="the_function()">Click Me</button>
                  

                  the_script.php 里面有这个:

                  the_script.php has this in it:

                  the_function() {
                      echo "You win";
                  }
                  

                  为什么这不起作用?我听说按钮是客户端等,而 PHP 是服务器端,这意味着您不能将两者链接在一起.我知道你必须使用 AJAX 来完成这项工作,但是我完全不知道如何去做.我试过用谷歌搜索它等等,但是我什么也找不到.我知道如何使用 AJAX 并用它调用事件,但是我仍然不知道如何让它调用 PHP 脚本.

                  Why isn't this working? I've heard about the button being client side etc. and PHP being server-side, which means that you cannot link the two together. I know that you have to use AJAX to make this work, however I legitimately have absolutely no clue how to do it. I've tried googling it etc., however I can't find anything. I know how to use AJAX and call events with it, however I still have no idea how to make it call a PHP script.

                  你能否让你的答案尽可能简单明了,我是新手

                  Can you please make your answers as clear and simple as possible, I'm new to this

                  感谢您的帮助:)

                  编辑***

                  出于某种原因,无论我走到哪里,每个人的代码都是不同的.我学习 AJAX 的方式看起来完全不同.你能这样写,让我明白吗?谢谢,这是一个例子:

                  For some reason wherever I go everyone's code is different. The way I have been taught AJAX looks completely different. Can you please write it this way so I can understand? Thanks, here's an example:

                  var request;
                  
                  if (window.XMLHttpRequest) {
                      request = new XMLHttpRequest();
                  } else {
                      request = new ActiveXObject("Microsoft.XMLHTTP");
                  }
                  
                  request.open('GET', 'file.php', true);
                  
                  request.onreadystatechange = function() {
                  
                      if (request.readyState===4 && request.status===200) {
                          do stuff
                      }
                  }
                  
                  request.send();
                  

                  推荐答案

                  试试这个:

                  <button type="button">Click Me</button>
                  <p></p>
                  <script type="text/javascript">
                      $(document).ready(function(){
                          $("button").click(function(){
                  
                              $.ajax({
                                  type: 'POST',
                                  url: 'script.php',
                                  success: function(data) {
                                      alert(data);
                                      $("p").text(data);
                  
                                  }
                              });
                     });
                  });
                  </script>
                  

                  在script.php中

                  In script.php

                  <?php 
                    echo "You win";
                   ?>
                  

                  这篇关于如何在 html 按钮单击时调用 php 脚本/函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    1. <i id='g8Hml'><tr id='g8Hml'><dt id='g8Hml'><q id='g8Hml'><span id='g8Hml'><b id='g8Hml'><form id='g8Hml'><ins id='g8Hml'></ins><ul id='g8Hml'></ul><sub id='g8Hml'></sub></form><legend id='g8Hml'></legend><bdo id='g8Hml'><pre id='g8Hml'><center id='g8Hml'></center></pre></bdo></b><th id='g8Hml'></th></span></q></dt></tr></i><div id='g8Hml'><tfoot id='g8Hml'></tfoot><dl id='g8Hml'><fieldset id='g8Hml'></fieldset></dl></div>
                      <tfoot id='g8Hml'></tfoot>
                        <tbody id='g8Hml'></tbody>
                      <legend id='g8Hml'><style id='g8Hml'><dir id='g8Hml'><q id='g8Hml'></q></dir></style></legend>
                      • <bdo id='g8Hml'></bdo><ul id='g8Hml'></ul>

                          1. <small id='g8Hml'></small><noframes id='g8Hml'>