I'm programming a currency converter, and to not have to manually update the current currency, I get the current value from another website trough AJAX and Whatever Origin (to allow access to another domain). I tested it in a separated page and it worked perfectly, i.e. showed the current currency. However, when I inserted it in the actual code of the converter ...
... any console accuses illegal character inside the jQuery file, even if I link to Google's library:
SyntaxError: illegal character jquery.min.js:1:4
ReferenceError: $ is not defined Converter.html:75:0
Wherever I put it (in the beginning, middle or end), the same error happens, but only if I insert my code there, if I only link the jQuery file, no errors are showed.
$.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 move to: here.
The working test page: here.
I don't even have a clue of what is happening..
After many tweaks, finally I got rid of that error! What I did:
First I moved the contents of the actual page to the test page. Then I moved my script to a separated .js file. Then the error accused "illegal character" for arithmetic symbols (/ and *) in the functions in 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 was the real error, the only things I know is that it wasn't an "illegal character", and doing what I did fixed that.
By the way, thanks for the attention to who tried to help, even though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With