0
我想用jQuery学习ajax,但我的脚本似乎不工作 我用表单来查看script.php文件是否有问题,但它工作正常精细。 当我点击sendAjax按钮时,什么也没有发生。我检查Firefox上的开发工具中的网络选项卡,看起来没有任何东西发送。 我也尝试发送数据json样式但不工作{'data':'Data'} 即使我在php脚本上回显某些内容也不起作用。 我认为这只是一个愚蠢的错误,但因为这是我的第一个ajax脚本,我很难找到它Post ajax请求没有达到php
这是我的脚本。 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);
}
也许成功而不是成功? – Bernhard
其错字。 'succes' – RRK