+ 3
SoloLearn App: ReferenceError: Can't find variable: $ at Line:
I use jquery in a code like $(function(){โฆ}); in the SoloLearn App. I get the error ReferenceError: Can't find variable: $ at Line:โฆ I get the error by separating the jquery code in the js area. No error is occured by use the js code in the html area with script tag. This behavior is new and only in the mobile SoloLearn App. The error donโt occur in the Webbrowser from SoloLearn. Maybe a bug? Or what is the error? https://code.sololearn.com/WocKD43r40eC
20 Answers
+ 7
KrOW & asa22 Thanks, I was about to post the same question. I'm on iOS and had always found the same error reviewing codes from other SoloLearners.
+ 5
asa22 No "JS Content" is printed? ๐
Anyway it seem like a bug. it works differently from android which execute at last the js tab content (like Ipang said).
A fast half-solution is execute your js code on window load like:
window.load= function(){
$('p').click(...);
}
to be sure that js is loaded
+ 5
asa22 I want inform you that the problem would be solved in the next-upcoming iOS release... Feel free to inform me if it will work (or not) when you will update the app (i dont know the date of next release but it not would be far) ๐
+ 3
Is it possible that the JS code in the JS pane was executed before the jQuery file was read from <script src ...>? I once read that SoloLearn inserts the JS pane content in the beginning of the document <head> section, it might be that's the reason, because as asa22 said, the script runs just fine if it is in the <head> section, assumed after the <script src>.
+ 2
asa22 Sorry for late reply. Yes, it is a possibility, but I'm not sure if it works the same between Android and iOS.
I tested by opening your code in my old Android phone for editing, and put alert("jQuery loaded") below the jQuery <script src> in HTML pane, and another alert("JS pane loaded") below the code in JS pane, but from my observation, the message "jQuery loaded" comes first, followed by "JS pane loaded", so I'm still not so sure why it happened.
Anyways, as a side note, your code runs just fine here in my phone, I hope you can find a solution for this soon ๐
+ 2
On sl the js tab content is inserted at end (eg. as last child) of head of generated html document (which is executed by web engine).
At least so works on android but i dont think that on iOS is different ๐
+ 2
asa22 can you execute this
https://code.sololearn.com/W8W0w5xcgXi0/?ref=app
and tell me what is printed on console?
+ 2
KrOW Thank you very much for your efforts :)
my iOS device has the latest version
concole say only
ReferenceError: Can't find variable: $ at Line: 3
test
+ 2
It has to do with ios, try wrapping the whole thing in window.onload = function (){}works for me .
+ 1
asa22 Just for understand: if you run the code without edit it (like its now), the error raise or not?
+ 1
asa22 Strange... I have not problem with it... Have you tried to run on your device browser right? It works on it?
+ 1
asa22 Can you copy/paste the complete error message?
0
hi r8w9, thank for your answer
i am using the latest version of sololearn for ios with iPad. maybe this?
0
yes, only in the mobile device and with separating the jquery code in the js area.
therefore i made the script in the html disabled.
0
yes, the error raise with this code.
this behavior is new, last year in december i have no problem with this.
0
KrOW
I have no problem with safari and https://www.sololearn.com, only with the app.