0
下面是我的代碼:獲得空數組時通數據從PHP jQuery的
<script src="jquery-1.8.3.js" type="text/javascript">
</script>
<script type="text/javascript">
var obj=[] ;
function getData(){
$.ajax({
url:'jqueryJsonTest.php',
type:'POST',
dataType: 'json',
cache: true,
success:function(data){
obj = data ;
alert ("alert 1: "+obj.length);
}
});
}
$(document).ready(function() {
getData();
alert("alert 2: "+obj.length);
alert("alert 3: "+obj.length);
});
</script>
爲什麼保存數據的空數組後的第一個結果?
非常感謝。這已經解決了我的問題。 –