jquery - Variable Id not increasing? -


in following code, variable id not increasing each loop updated current code

here code, thanks

(function (d, s) { s = d.createelement('script'); s.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.js'; (d.head || d.documentelement).appendchild(s); s.onload = function () {     jquery.noconflict();     jquery(function ($) {         var id = 158066137;;         var link = 'http://api.roblox.com/marketplace/productinfo?assetid=' + id;         function scan(val) {             link = 'http://api.roblox.com/marketplace/productinfo?assetid=' + id;             $.get(link, function (data) {                 var value = data;                 if (data.creator.id == 1 && data.creator.name == 'roblox') {                     var msg = "created " + data.creator.name + "\nobject name " + data.name + "\nasset id " + data.assetid                     console.log(msg);                 }             });         }         setinterval(function() { scan(true); id++ }, 0);     }); } })(document); 

i think problem line $(document), $ referring other library other jquery(which might using document.queryselectr()).

so solution try move script onload handler of dynamic script element like

(function (d, s) {     s = d.createelement('script');     s.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.js';     (d.head || d.documentelement).appendchild(s);     s.onload = function () {         //rever value of $ old 1         jquery.noconflict();         //use jquery instead of $ refer jquery object         jquery(function ($) {             setinterval(function () {                 var id = 158066137;                 var link = 'http://api.roblox.com/marketplace/productinfo?assetid=' + id;                 $.get(link, function (data) {                     var value = data;                     if (data.creator.id == 1 && data.creator.name == 'roblox') {                         var msg = "created " + data.creator.name + "\nobject name " + data.name + "\nasset id " + data.assetid                         console.log(msg);                     }                     id++;                 });             }, 0);         });     } })(document); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -