时间:2021-07-01 10:21:17 帮助过:5人阅读
var test={};
test.getflash = 2;
test.test =function(){
alert(this.getflash); //2
$.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert(this.getflash); //等于undefine
}
});
}
解决方法:
代码如下:
test.test =function(){
var thisValue = this;
alert(thisValue.getflash); //2
$.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert(thisValue.getflash); //2
}
});
}