[Solved] Why isn’t this jquery code working with for loop and $.get


Your syntax in faulty, try to open your file in for example Chrome Developer’s Tools: you’ll get a Uncaught SyntaxError: Unexpected identifier. This is because JavaScript isnt’ C: you cannot define a variable to be a type, like you do on line 9, you need to define it using the var keyword like this:

for(var i = 0; i < 10; i++){
      $.get("http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_ajax_get",function(data,status){
  //alert("Data: " + data + "\nStatus: " + status);
});

Running that on the editor of w3schools work for me.

6

solved Why isn’t this jquery code working with for loop and $.get