欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ajax異步回調(diào)函數(shù)中給外部變量賦值的問題探討

 更新時(shí)間:2013年09月27日 17:37:41   作者:  
ajax異步回調(diào)函數(shù)中給外部變量賦值的問題在本文將為大家詳細(xì)探討下,感興趣的朋友可以參考下
復(fù)制代碼 代碼如下:

<!doctype html>
<head>
<meta charset="utf-8">
</head>
<body>
<script src="http://localhost/UIBMSPHPProj/public/js/jquery-1.8.2.min.js"></script>
<script>
$(function(){
var str = "aaa";
$.post("http://localhost/UIBMSPHPProj/index.php/Index/abc",{},function(data){
//data = "bbb";
console.log(str);//aaa
str = data;
console.log(str);//"bbb"
});
console.log(str);//"aaa"
});
</script>
</body>
</html>

ajax回調(diào)函數(shù)異步的原因?qū)е铝嗽谕獠恐苯荧@取str的值時(shí)還是“aaa”,需要用“bbb”時(shí),可以將用"bbb"的函數(shù)放入回調(diào)函數(shù)中調(diào)用。

相關(guān)文章

最新評(píng)論