我试图根据不同的按钮点击运行多个php脚本。 当使用点击按钮时,我不希望页面重新加载,只是基本上运行PHP脚本。使用Ajax按钮单击运行多个php脚本点击
这是我的代码,但由于某种原因,我无法得到以下代码来工作。
我想我没有正确调用按钮ID。
<html>
<head>
<title>Example</title>
<script>
$('.myButton').click(function() {
$.ajax({
type: "GET",
url: "run.php"
}).done(function(resp) {
alert("Hello! " + resp);
});
});
$('.myButton2').click(function() {
$.ajax({
type: "GET",
url: "run1.php"
}).done(function(resp) {
alert("Hello! " + resp);
});
});
$('.myButton3').click(function() {
$.ajax({
type: "GET",
url: "run2.php"
}).done(function(resp) {
alert("Hello! " + resp);
});
});
</script>
</head>
<body>
<input type="button" value="Click" id="myButton" />
<input type="button" value="Click" id="myButton2" />
<input type="button" value="Click" id="myButton3" />
</body>
</html>
这里有没有PHP的,所以为什么标签? –
1)http://idownvotedbecau.se/beingunresponsive 2)http://idownvotedbecau.se/nomcve/ –