jquery - Have to paste in console twice in order to get results? Also saying undefined is not a function? -


in following code, if paste in console, error syntaxerror: failed execute 'queryselector' on 'document': '[object htmldocument]' not valid selector.

if ignore error , paste again before refreshing browser, code goes through, returning error uncaught typeerror: undefined not function

please help, code, thanks!

also please note have on page run it, am

(function(d,s){s=d.createelement('script');s.src='https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js';(d.head||d.documentelement).appendchild(s)})(document); $(document).ready(function() { var id = 158066137; var link = 'http://api.roblox.com/marketplace/productinfo?assetid=' + id; setinterval(function() {     $.get(link, function(data) {         var value = data;         var isrobloxmade = value.indexof('"creator":{"id":1,"name":"roblox"}');         if (isrobloxmade >= 0) {             console.log(value);         }     }); }, 10); }); 

first of all, knowledge it's not possible load jquery asynchronously without helper library such jqi. specific error you're seeing because browsers have mapped $ document.queryselectorall , expect css selector.

secondly, jquery automatically turns json response object doesn't have .indexof() method. code should therefore be:

if (data.creator.id == 1 && data.creator.name == 'roblox') {     console.log(data); } 

Comments

Popular posts from this blog

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

Python ctypes access violation with const pointer arguments -

jquery - Keeping Kendo Datepicker in min/max range -