Illegal character in the jQuery library file, even without an invisible character or missing quote anywhere

What am i trying to do

I am programming a currency converter, and I do not need to manually update the current currency, I get the current value from another site through AJAX and Whatever Origin (to allow access to another domain). I tested it on a separate page and it worked perfectly, i.e. Showed current currency. However, when I pasted it into the actual converter code ...

Error

... any console blames the illegal character inside the jQuery file, even if I reference the Google library:

SyntaxError: illegal character jquery.min.js:1:4 ReferenceError: $ is not defined Converter.html:75:0 

Wherever I am (at the beginning, in the middle or at the end), the same error occurs, but only if I paste my code there, if I only link the jQuery file, no errors are visible.

Code

 $.getJSON('http://whateverorigin.org/get?url=' + encodeURIComponent('http://usd.fx-exchange.com/brl/') + '&callback=?', function (data) { currency = $('.today_s', data.contents).html(); currency = currency.match(/\d\.\d\d\d\d/); }); 

The page I'm trying to go to is here .

Working test page: here .


I don’t even know what is going on.

+5
source share
2 answers

After many tricks, finally, I got rid of this error! What I've done:

First, I moved the contents of the actual page to the test page. Then I moved my script to a separate .js file. Then the error accused the "illegal character" for arithmetic characters (/ and *) of functions at the beginning of the file. So I moved them to the end. Then I moved the jQuery code to the beginning of the .js file. Then finally I got free! = D

I don’t know what the real mistake was, the only thing I know is that she was not an “illegal character” and did what I corrected.

By the way, thanks for the attention to the one who tried to help, though.

+2
source

Check your js link and you should run jQuery code after loading jquery:

 $(document).ready( function() { $.getJSON('http://whateverorigin.org/get?url=' + encodeURIComponent('http://usd.fx-exchange.com/brl/') + '&callback=?', function (data) { currency = $('.today_s', data.contents).html(); currency = currency.match(/\d\.\d\d\d\d/); }); }); 
0
source

All Articles