简体   繁体   English

非常简单的AJAX-Call不起作用

[英]Very simple AJAX-Call does not work

This very simple AJAX-Call does not work on my localhost. 这个非常简单的AJAX-Call在我的本地主机上不起作用。 I do have a Windows 10 Machine with XAMPP running. 我确实有运行XAMPP的Windows 10计算机。 I tracked the packages, and the AJAX-Reqauest is not even sent to handle.php. 我跟踪了软件包,并且AJAX-Reqauest甚至没有发送到handle.php。 What am i doing wrong here? 我在这里做错了什么?

ajaxTest.php ajaxTest.php

<html>
    <head>
        <script src="https://code.jquery.com/jquery-3.2.1.min.js">
        $(document).ready(function()
        {
            $.ajax(
            {
                type: 'post',
                url: 'inc/handle.php',
                success: function(data)
                {
                    alert("Done!");
                }
            });
        });
        </script>
    </head>
</html>

handle.php handle.php

<?php
echo "Test!";
?>

The problem is: include jquery on script tag and your code into another script tag 问题是:在脚本标签上包含jquery,并将您的代码包含到另一个脚本标签中

<html>
    <head>
        <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
        <script>
          $(document).ready(function()
          {
            $.ajax(
            {
                type: 'post',
                url: 'inc/handle.php',
                success: function(data)
                {
                    alert("Done!");
                }
            });
          });
        </script>
    </head>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM