jqueryを使用してネストされたajax呼び出しで 'button one'を 'button two'、 'button two'を 'button three'、 'button three'を 'button ok'と置き換えたい。ボタン1をボタン2に置き換えた後は機能しません。どこが間違っていますか?助けてください。jqueryがネストされたajaxコール
<!--This is my html code.......-->
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
</head>
<body>
<button id="one">button one</button>
<script>
$(document).ready(function(){
$("#one").click(function(){
$.post("show.php",
{
id: "two"
},
function(data,status){
document.getElementById("one").innerHTML = data;
});
});
$("#two").click(function(){
$.post("show.php",
{
id: "three"
},
function(data,status){
document.getElementById("one").innerHTML = data;
});
});
$("#three").click(function(){
$.post("show.php",
{
id: "ok"
},
function(data,status){
document.getElementById("one").innerHTML = data;
});
});
});
</script>
</body>
</html>
これはshow.phpページコード
<?php
$id=$_REQUEST["id"];
echo"
<button id='$id'>button $id</button>
";
?>
はい、その可能 – Bharat
技術的にはあなたのAjax呼び出しが* *ネストされていません。ちょうど別々に呼ばれた全体の目的は何ですか? –
ボタンを追加した後でオンクリックを追加する必要があります。または、$( 'body')を実行してください。 'click'、 '#two'、function(){') – Timmetje