通过javascript jquery传递变量

时间:2016-07-12 03:21:57

标签: javascript jquery

我的头衔可能不合情理,但这是我的问题。我有一个for循环,它在jquery中执行get请求,但我无法读取for循环中任何已定义的局部变量,因为它会在循环中被重写时

for(i=0;i<10;i++){
    var Something = i 
    $.get("http://example.com",function(){
        console.log(Something)
    })
}

输出将是 10 10 10 10 10 10 10 10 10 10

我如何将Something变量传递给函数?

0 个答案:

没有答案