How to debug when javascript doesn't load - javascript

I have 2 sites using the same theme. (http://www.kentishtowner.co.uk and http://here-is.com/kentishtowner-old/ )
They are WP multisite subsites, both using the exact same child theme (same template files exactly).
However, the former website is not loading javascript, causing the masonry layout and mobile menu to not work!
I assume this is something to do with when I mapped the domains, or changed the URL from something like here-is.com/kentishtowner-new to here-is.com/kentishtowner, before domain mapping...
As I am not a JS person, can someone give me some insight as to how I can go about debugging this?
I haven't slept a wink last night and it's now 11am - am getting an hour's shuteye, and would hugely appreciate any responses!
Thanks!

In Chrome's console you'll see
Resource interpreted as Script but transferred with MIME type
text/html:
"http://here-is.com/?dm=c078877dcf0e3101dc20cc337a8e4214&action=load&blogid=13&siteid=1&t=1522670393&back=http%3A%2F%2Fkentishtowner.co.uk%2F".
In fact, further digging shows that here-is.com is returning an empty response to that request.
The page is actually referring absolutely to a number of resources on here-is.com and that works fine when you access it via that domain, but has issues when you access via www.kentishtowner.co.uk. I don't know enough about your setup to say for sure how to resolve it but you probably need to configure the base URL of the project to tell it where it's being deployed, or if you can tell it to use relative links that would work too.
(In Chrome's developer tools you can hit ctrl+shift+F and type here-is.com to see the references)

Browsers have consoles where javascript errors are thrown. They will tell you what error was thrown, and where it was thrown from. Once you know that, you can google around to see if there is anything obvious to fix.
My guess, though, is that somewhere the site that isn't working is trying to use a script that was hosted on the working site. If that's the case, you just need to update the script paths.
--edit--
Fortunately for me (from what I hear), I have never used Wordpress. Unfortunately for you, I don't know how to tell you where the .js files would be located, or how they are organized at all.
I usually debug in Chrome, so this is how you can check to see if your page is able / unable to get an external script.
When you are focused on the page you're having a problem on, hit F12 to open up the dev tools in Chrome.
Click on the Network tab, and then hit F5 to refresh the page.
Click on the Type table header, and look for files that say text/javascript. Those will be the external script files your site is requesting.
Look at the Status column for each of those rows. If it doesn't say 200 OK., then your page isn't able to access the corresponding script.
From there, you would need to find where those scripts are supposed to be located. Once you know that, just find the scripts from the other site, and copy them into the correct location of the broken site.
Good luck!

Related

not seeing a specific resource on a web page

i have a strange problem with a web page!and i can't see it in none of my browsers while all of my coworkers see it and work with it all well!
however if i use a vpn i can see it with no problem!
so i assume it is not my browser problem since i can see it contents with vpn
the strange part for me is that i can see title and html content but when it wants to fetch CSS and JS resources it gives (failed) net::ERR_CONNECTION_RESET!
i tried ping and trace rt and both of them was successful!
(and as i said i can see title of page and it first page that is a small page)
so i am not blocked by anything.
i also changed my internal network to something else and still it wouldn't loads up!i insert an image of what page is load in first place.
i don't know if it is relevant or not but the website is written with GWT
if anymore information is needed i be more than to happy too providing it.
i used firefox, chrome,edge,ie and none of them shows page!
i insert an image to show what is loaded
html page is loaded:the html page that is loaded and page content
resources that give error:the resources that fail to load
PS: sorry if cleared addresses out, i didn't know if it is right or not with the company to include them so i cleared them out.

403 (forbidden) on end user's console

I have an application that seems to be working across the internet. But I fielded a call from an end-user who is having difficulty using the website
I asked her to send a screenshot of the console error and recieved this:
From searching stackoverflow it looks like its a permissions issue, but the site works for everyone else. Is this on her end or mine?
UPDATE I should've mentioned that is user works from a school. Perhaps her IT admin has blocked some internet resources?
Have end-user tried different browser? i would say it's some plugin stopping to load that script. If your app is working everywhere then it can't be your app. Ask end-use to try another browser and for check if end-user has any plugin witch can also cause this.
The problem may also come from lealfet or google map.
We can se that the page is currently loaded, css ans content seems fine, only the map part seems to be broken. So i don't think there is a problem with your server/website, I would put the fault on the others.
Note : we see that leaflet only is concerned when looking carefully at the screenshot.
Edit : in some cases, you can make a local copy of these external file, check whether the user need them or not, then load them as rescue.
Update : Either the school did block leaflet, or leaflet did automatically block the school as their bandwich use can excess what they allows by user, or due to abuse of any kind.

Microsoft Word download from web server issue

I am trying to troubleshoot the following issue. A client tried to download a word document and is getting the following error.
Your organization's policies are preventing us from completing this action
for you. For more info, please contact your help desk.
I believe this issue is because of cross-domain javascript. However, the file is being downloaded from a pop-up that doesn't stay on the screen long enough for me to do anything. It is an issue with IE8 / 9.
I can not find which javascript is opening the popup let alone which javascript is being run from within the popup. I am using fiddler to try and view the http requests and that is not helping.
Is there a way for me to debug what is happening within that popup? Is there a way to debug javascript to break on a type of condition being met?
EDIT:
I have tried working on this issue on my local environment and the same issue comes up. The popup appears to first come from the same domain https://company.aj.com, then goes to a different domain https://apps.aj.com and the file is being downloaded from the apps domain.

Advert javascript not being served correctly to the browser unless called directly?

I hope this is the right place to ask this question - I did have a look at the rest of the sites in the network but this looked like the most appropriate place.
We are having issues serving third party adverts on our websites. For various reasons our ad setup is a bit complicated - we serve third party javascript tags (AppNexus) through our own ad server (OpenX) through iframes. Currently, the third party javascript tags are not showing correctly, although they have worked just fine in the past.
Debugging this in Safari I have discovered a few things which seem to me to be a bit unusual, and I'm struggling to work out what's going on. Using the web inspector to check the third party's javascript, it appears in the web inspector as a blank file. Additionally, if I check the network tab, the headers are shown and look fine, but there is no 'content' tab with which to check the returned content. The network tab shows the request for the file as complete, and with suitable status codes (200/302):
http://cl.ly/401C1D3Y3u2G2k2k3s0x
However, if I load the file directly in the web browser, it loads fine:
http://ib.adnxs.com/ttj?id=694021&cb=[CACHEBUSTER]&pubclick=[INSERT_CLICK_TAG]
FWIW, the javascript file uses document.write to spit out either an image or another iframe. It's also worth mentioning that there are no related errors in the console - there is one relating to Google Ads, but the problem persists if I load the Ad server's iframe directly without the rest of the site.
Has anyone seen this behaviour before, where a file loads just fine directly, but is (blank / not retrieved / not parsed / whatever's going on) when called as part of another page? If so, would you be able to help me fix this?
Thanks in advance for any help you can give me - I hope this makes some sense and will be happy to provide any further information that might help me get to the bottom of this!
Ollie
I'm guessing that the third party site is filtering output from their servers based on the HTTP referer being sent in the request (a technique employed by many web hosts to thwart hot-linking content). Try putting the link to the javascript file in a clickable link on a web page on your server and click it and then see if it loads or if you get a blank page. You could also try loading a browser extension which lets you forge the HTTP Referer (such as RefControl for Firefox) and then change your refer to be your site instead of the third party's and try pasting in the URL to the browser and see if it loads.
This isn't your fault if it's what turns out to be the actual problem. It's up to the third party to configure their web host to allow for this.

JavaScript working differently locally than online

I've noticed that some simple scripts in JavaScript that work perfectly on my local server don't work at all online.
How can be this possible? JS client-side scripting? Any ideas?
Sorry for not providing much information, and for my English, too.
Mine was a general question.
For example:
$('#posticipa').click(function(){
var stato = $('#future').css('display');
if(stato == 'none'){$('#future').css('display', 'block');}
else{ $('#future').css('display', 'none');}
});
This piece of code works perfectly on my local Apache server on Ubuntu 9.10, with Firefox 3.6, 3.5, Google chrome and Opera.
When I upload it on my remote CentOS server, also running Apache, it doesn't work. No errors are displayed in Firebug or the console; it just doesn't run.
I'm using the same version of jQuery on both servers.
Check console in your browser for errors. If it is Firefox - install firebug, if it chrome - press Ctrl + Alt + J.
It depends on what your script is trying to do. "Any ideas?" is pretty broad. But client-side scripting has a lot more restrictions than server-side, for obvious security reasons. For example, if you could access the client's file system through client-side JS, any website on the internet would be able to take control of your system.
JavaScript Security Restrictions
Having looked at your edited question, I think it's most likely that one of two things is happening:
Some kind of error is causing the JS to fail before this code is hit (but you say FireBug isn't displaying an error, so if you've got FB set up right this shouldn't be the problem)
The entire script is never getting hit, probably due to an incorrect src attribute in the script tag.
Try putting a debugger; line or an alert somewhere very early in your JS code. That should tell you whether the script is getting hit (the debugger command should tell FireBug to go into debug mode, provided you have FB's Script tag enabled on when you load the page).
If it isn't getting hit, make sure the script's src is the correct, reachable URL. If it is, move the line steadily down your code until it doesn't fire anymore. That should help you figure out where the error is.

Categories