Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.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
Jquery 函数的作用是';不能使用引导_Jquery_Html_Ajax_Post_Xampp - Fatal编程技术网

Jquery 函数的作用是';不能使用引导

Jquery 函数的作用是';不能使用引导,jquery,html,ajax,post,xampp,Jquery,Html,Ajax,Post,Xampp,从一段时间以来,我一直无法使post功能正常工作。我已经尝试了我在互联网上找到的一切,但似乎没有任何帮助。 这些是我的文件: <html> <head> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorig

从一段时间以来,我一直无法使post功能正常工作。我已经尝试了我在互联网上找到的一切,但似乎没有任何帮助。 这些是我的文件:

<html>
<head>
  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">

  <script>
  $(document).ready(function(){
    $("#sendButton").click(function(){
      event.preventDefault();
      var text = document.getElementById("xd").value;
      $.post("reg_send.php",
      {
          name: text
        },
        function(data){
          $("#xd").html(data);
        });
        $("#xd").html("Trying");
    });
  });
  </script>

</head>
<body>
  <form style="width: 70%; margin: 0 auto;">
    <p id="xd">TextHere</p>
    <button type="button" class="mx-auto btn btn-danger" id="sendButton" data-toggle="collapse" data-target="#collapse1">Enviar</button>
  </form>

</body>
</html>

$(文档).ready(函数(){
$(“#发送按钮”)。单击(函数(){
event.preventDefault();
var text=document.getElementById(“xd”).value;
$.post(“reg_send.php”,
{
名称:text
},
功能(数据){
$(“#xd”).html(数据);
});
$(“#xd”).html(“尝试”);
});
});

text此处

羡慕
以及reg_send.php文件:

<?php
echo "working";
?>

但它就是不起作用,我也不明白为什么。我也尝试过使用这个,但没有:

  <script>
    function send(){
     $.post('reg_send',{},
      function(data){
        $("#Titulo").html("Xd");
      });

      }
  </script>

函数send(){
$.post('reg_send',{},
功能(数据){
$(“#Titulo”).html(“Xd”);
});
}
并在单击按钮时调用send()。我想使用瘦o作为XAMPP服务器,也尝试在那里设置它,但什么都没有。
提前感谢。

这里,您使用的是jQuery的精简版,它没有AJAX的$.post()功能

使用此处提供的完整版本,例如:

<script src="https://code.jquery.com/jquery-3.3.1.min.js" ></script>

jquery slim不支持ajax方法,为了在jquery中使用ajax,您需要使用jquery.min.js或jquery.js

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script>
    $(document).ready(function(){
        $("#sendButton").click(function(){
            $.ajax({
                type: 'POST',
                url: 'reg_data.php', 
                data: 'Hello'
            })
</script>

$(文档).ready(函数(){
$(“#发送按钮”)。单击(函数(){
$.ajax({
键入:“POST”,
url:'reg_data.php',
数据:“你好”
})