私の実際の例では、私は非常に簡単な例を作っあまりにも大きいので:jquery/ajaxでシンプルなPHPコードを実行するには?
test1.php
<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <!--jQuery-->
<body>
<p> What is the first letter of the alphabet?</p>
<button type="button" id="button">Tell me!</button>
<div id="div"></div>
<script>
$(document).ready(function(){
$('#button').click(function(){
$.ajax({
url: 'test2.php',
success: function() {
$('#div').html();
}
});
});
});
</script>
</body>
</html>
test2.php
<?php
echo "It's the letter A!";
?>
私はこれにしたいです「それは文字Aです!」と印刷します。私はボタンを押すと、動作していないようです。誰かがなぜこれがうまくいかず、どうやって解決するのか教えてもらえますか?
ありがとう
は '$( '#button')'、 – JYoThI
のように引用符で囲む必要があります。レスポンスは何もしなかったので、[$ .ajax](http://api.jquery。 com/jQuery.ajax /) –
あなたは正しいです!それを修正しましたが、それでもLOLは動作しません。 – Denis