javascript - PriceSelling is not defined. But, it is -


i getting error priceselling not defined. is, infact know on page because logs in console. please help! thanks

$.get(window.location, function(data){    var regex=/<span class="it " data-se="item-privatesale-price">([\d,]+)<\/span>/;    var priceselling = data.match(regex)[1];       console.log(priceselling); });  function get(name){    if(name=(new regexp('[?&]'+encodeuricomponent(name)+'=([^&]*)')).exec(location.search))       return decodeuricomponent(name[1]); }   if (get('bot') && get('expecting') && get('expecting') == priceselling) { console.log("it's go!"); document.getelementsbyclassname('conf-buy-now btn-primary btn-medium purchasebutton ')[0].click(); //document.getelementbyid('conf-confirm-btn').click(); };  

it defined in scope of callback function passed $.get.

but not defined in global scope.

you

var priceselling;  $.get(window.location, function(data){   var regex=/<span class="it " data-se="item-privatesale-price">([\d,]+)<\/span>/;   priceselling = data.match(regex)[1];     console.log(priceselling); });  function get(name){   if(name=(new regexp('[?&]'+encodeuricomponent(name)+'=([^&]*)')).exec(location.search))     return decodeuricomponent(name[1]); }   if (get('bot') && get('expecting') && get('expecting') == priceselling) {   console.log("it's go!");   document.getelementsbyclassname('conf-buy-now btn-primary btn-medium purchasebutton ')[0].click();   //document.getelementbyid('conf-confirm-btn').click(); }  

but while wouldn't referenceerror, wouldn't since priceselling undefined.

but notice trying use response right away. have use in callback, called once response has been received.

you might benefit how return response asynchronous call?.

$.get(window.location, function(data){   var regex=/<span class="it " data-se="item-privatesale-price">([\d,]+)<\/span>/;   var priceselling = data.match(regex)[1];     console.log(priceselling);    function get(name){     if(name=(new regexp('[?&]'+encodeuricomponent(name)+'=([^&]*)')).exec(location.search))       return decodeuricomponent(name[1]);   }     if (get('bot') && get('expecting') && get('expecting') == priceselling) {     console.log("it's go!");     document.getelementsbyclassname('conf-buy-now btn-primary btn-medium purchasebutton ')[0].click();     //document.getelementbyid('conf-confirm-btn').click();   }  }); 

Comments

Popular posts from this blog

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

c# - How do I get the Nth largest element from a list with duplicates, using LINQ? -

jsp - "Sending a redirect is forbidden after the response has been committed" in sendRedirect -