我想在我的ajax响应中访问变量“维度”,但无法获取它。我不想让这个变量全局。以下是我的代码
javascript中的范围变量,jquery
$(document).ready(function(){
$('#submittext').click(function(){
var dimensions;
$.ajax({
type: "GET",
url: "bin/getcontentsize.php",
data: findContentsize,
success: function(response){
//want to access dimensions here to assign response and some calculation(but not able to access it)
}
});
//so i can use here
});
});
你是什么意思,你不能访问它?它会产生一个错误,错误的值等... – JaredPar
你应该可以很好地访问尺寸。然而,它将会是'未定义'的,因为你从未初始化它。 – samjudson
@samjudson是的,它说没有定义 –