簡體   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