I expected the code below to alert \"0\" and \"1\", but it alert \"2\" twice. I don\'t understand the reason. Don\'t know if it is a problem of jQuery. Also, please help me
Alternative to SLaks' answer
$(function() { for (var i=0; i<2; i++) { $.get('http://www.google.com/', function(i) { return function() { alert(i); } }(i)); } });