您可以使用javascript闭包:
for (var i = 0; i < arr.length; i++) { (function(i) { // do your stuff here })(i);}或者您可以使用
$.each:
var arr = [2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010];$.each(arr, function(index, value) { $.ajaxSetup({ cache:false }); $.getJSON("NatGeo.jsp", { ZipCode: value, Radius: document.getElementById("radius").value, sensor: false }, function(data) { DrawZip(data, value); } );});


