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&currencytype=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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -