jquery - AJAX called within JavaScript closure (triple nested for) -


i've tried using this: javascript closure inside loops – simple practical example

but cannot head around how does:

arrayone[0]      secondarray[0]                thirdarray[0]                thirdarray[1]                thirdarray[2]      secondarray[1]                thirdarray[0]                thirdarray[1]      secondarray[2]                thirdarray[0]                thirdarray[1]                thirdarray[2] arrayone[1] //and on... 

i want call ajax post within every thirdarray loop therefore i've been informed must use closures instead of simple triple nested loops.

using first, second , third array can show me way works, more apparent if example fit purpose, dont understand how examples achieve want.

edit: (my attempt)

var ak47array = ['aquamarine revenge', 'wasteland rebel', 'jaguar', 'vulcan', 'fire serpent', 'point disarray', 'frontside misty',                   'cartel', 'redline', 'red laminate', 'case hardened', 'hydroponic', 'jet set', 'blue laminate', 'first class',                   'emerald pinstripe', 'elite build', 'black laminate', 'safari mesh', 'jungle spray', 'predator'];  var qaulityarray = ['factory+new', 'minimal+wear', 'field-tested', 'well-worn', 'battle-scarred']; var stattrack = ['normal', 'stattrack'];  var funcs = [];  (var = 0; < 3; i++) {     funcs[i] = (function(index) {         return function() {          };     }(i)); }  (var = 0; < ak47array.length; a++) {     funcs[0](console.log("my value: " + ak47array[a])); } (var b = 0; b < qaulityarray.length; b++) {     funcs[1](console.log("my value: " + qaulityarray[b])); } (var c = 0; c < stattrack.length; c++) {     funcs[2](console.log("my value: " + stattrack[c])); } 

this should do:

aquamarine revenge - factory new - normal aquamarine revenge - factory new - stattrack aquamarine revenge - minimal wear - normal aquamarine revenge - minimal wear - stattrack 

and on....


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -