對不起,如果我的標題不清楚,但我不確定如何形成問題/問題。 所以,我有這樣的代碼:
HTML:
<button onclick="test()">test</button><br>
的javascript:
function test(){
var text="Old text";
$.post('test.php',function(data){
text=data;
});
alert(text);
}
PHP:
<?php
echo "New text";
?>
但在警告框,我得到 「老文」 。 我該如何解決這個問題?
$。員額是AJAX。 AJAX的意思是**異步** JavaScript和XML。你需要閱讀這個:http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call –