繁体   English   中英

发布ajax请求未达到php

[英]Post ajax request doesn't reach php

我正在尝试使用jquery学习ajax,但是我的脚本似乎无法正常工作,我使用了表格来查看script.php文件是否存在任何问题,但它工作正常。 当我单击sendAjax按钮时,什么都没有发生。我在firefox上的开发工具中检查了网络标签,似乎没有任何发送。 我也尝试发送数据json样式,但也无法正常工作{'data':'Data'},即使我在php脚本上回显了某些内容也不起作用。 我认为这只是一个愚蠢的错误,但是由于这是我的第一个Ajax脚本,因此很难找到它

这是我的脚本。 index.html jQuery脚本

$(document).ready(function () {
    $("#sendAjax").click(function () {

        $.ajax({
            type: 'POST',
            url: "script.php",
            cache: false,
            data: {
                dataStr: 'Content'
            },
            succes: function (response) {
                alert("merge");
            }


        });
    });
});

index.html html

<div id='container'>
    <form action='script.php' method='POST'>
        <input type='text' name='username' id='username' placeholder="name">
        <input type='password' name='password' id='password' placeholder="password">
        <input type="submit" name='button' value="SendForm" id='button'>
    </form>
    <button id='sendAjax'>Send</button>
</div>    

script.php

<?php
    if(isset($_POST)){
        var_dump($_POST);
    }
succes: function (response) {
  alert("merge");
}

改成

success: function (response) {
   alert("merge");
}

暂无
暂无

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

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