javascript - My function is only working inside of the else in an if statement? -
if need edit function, please let me know. anyhow, i'm going through json table , getting id of item on roblox. in case don't work roblox, we'll use letters. if a's name b's asset id, change a's name b's name. that's want do, it's not working. here's if statement.
function loop(page) { $.get("https://search.roblox.com/catalog/json?subcategory=1&creatorid=62277089¤cytype=0&pxmin=0&pxmax=0&sorttype=3&sortaggregation=5&sortcurrency=0&includenotforsale=true&legendexpanded=false&category=1&pagenumber=" + page).success(function(data) { console.log("on page: " + page); (var = 0; < data.length; i++) { var prevname = data[i].name; if (!isnan(prevname)) { console.log("name number, changing...") $.get("https://www.roblox.com/item.aspx?id=" + number(prevname)).success(function(data) { var name = $("h1.notranslate", data).text(); edit(data[i].assetid, name); console.log("changed " + name); }); } else { edit(data[i].assetid, prevname); } } }); } (var = 1; < 4; i++) { loop(i); }
thanks help.
both of $.get
functions return data data
variable. try this
... if (!isnan(prevname)) { console.log("name number, changing...") $.get("https://www.roblox.com/item.aspx?id=" + number(prevname)).success(function(data2) { var name = $("h1.notranslate", data2).text(); edit(data[i].assetid, name); console.log("changed " + name); }); } else { edit(data[i].assetid, prevname); } ...
Comments
Post a Comment