Why Would Javascript Programming Work on One Server but Not Another - javascript

Someone else created a Javascript multipage form that works fine on a Host Gator server.
However, on the client's own Windows IIS server with an HTTPS path, it no longer works. It is not loading the Javascript.
Can anyone shed light on this? Is it an issue with Javascript version? Could it be a path issue or a case issue?

If you open your JavaScript console (F12, console tab), you'll see that Validator is not defined and is causing an error.
Above it, you'll also see that your JavaScript files are getting blocked for being served over http:// protocol instead of https:// (causing the scripts to not execute).
To solve that, you might need to host the files on your own server, or to use alternative CDNs (you can just add https to the jQuery URL, but it won't work for gen_validatorv4.js).

This was solved by placing the Jquery and Javascript files on the client server and referencing them with an absolute HTTPS path in the header.php file.

Related

Script tag is loading from file:/// instead of http://

I am working with a simple HTML test page. I am opening it with Chrome version 40.0.2214.115. In order to test the code, I am loading a js file from my workplace.
However, the file which I loaded tries to load other js files through script tags, but does not specify http:// . This causes an error in the console, as it defaults to the file:/// protocol and is unable to load file://the/restof/theurl.js
I downloaded the file locally, and loaded it from there, adding http:// to all url's, so it would ACTUALLY use the HTTP protocol.
This worked fine. However, those links load OTHER files that also do not specify http://
Is there any way I can have the browser imply http:// to unspecified script tags, and avoid downloading and editing EVERY file just to test a small HTML page?
I think the easiest way to prevent problems like this is to actually use a very small server (like something provided by node.js or the like or lighttpd).
Obviously your files are not supposed to be delivered via the plain file protocol, so you should just use a http server. That way you can be sure they work as intended and you don't have to fiddle around with your browser on a deeper level.
If you launch chrome with the below flags this should work. Obviously not possible for production environments, but for testing it should be okay.
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files
Consider using a simple local file server. If you are unsure how to, since you are developing in JavaScript, you can easily create a simple file server using Node.js which written in JS using simple middleware like node-static.

Sourcemap in jQuery 1.10.0 causes insecure content when loaded over HTTPS

i have a small problem by using HTTPS. By using SSL in my Rails-Application Chrome shows me the following error-message:
The page at 'https://www.thesitename.de/shop/counter/checkout/cart' was loaded over HTTPS, but displayed insecure content from 'http://www.thesitename.de/assets/jquery-1.10.0.min.map': this content should also be loaded over HTTPS.
Does that mean that the jquery-file is not loaded via HTTPS or that some requests in the jquery-script are over HTTP? In the sourcecode of the Site i don't see any HTTP-Javascript-includes. The jquery-File is local stored.
I hope this is enough information and someone can help me.
Thanks!
The file being requested forms the sourcemap for jQuery. This can be used by some browsers to help with debugging.
It's referenced in the download documentation here: http://jquery.com/download/
When looking at the problem elsewhere on stackoverflow I came across this:
sourceMappingURL from jquery generates 404 error in apache
There may be useful info in there.
My advice would be to try the following:
Remove the line from your jQuery library (this means that you won't have access to the sourcemap when you're debugging - which may not be a problem for you)
Use a CDN to source your jQuery libraries instead - both jQuery and Google have ones.
Try downloading a local copy of jquery-1.10.0.min.map beside your version of the jQuery distribution.
Hopefully one of the above should resolve your issue.

how to view source code for javascript src

I apologize in advance if this question is not appropriate for this forum. I could not find answers from searches in Google or Stackexchange. Also, because the question was specific, I thought I might be acceptable.
Background:
The end purpose is to troubleshoot a server connection error where a client machine runs javascript. I'm trying to at least determine the source and destination network ports used for the communication attempt.
I know zero javascript but have some background in C++.
The client runs this html page:
<script type="text/javascript" language="javascript" src="com.vmware.vim.cimmonitor.gwt.CimUi.nocache.js"></script>
Is there a way to view the contents of the specific js file? I cannot tell if the js file is bundled locally in some kind of javascript library or resides somewhere in vmware.com
I've tried to directly enter the full js name into firefox, but got a server not found error.
Thanks.
Press F-12 to open the browser's debugger. Open the NETWORK section. Reload the page. It will show you a complete list of resources as they are loaded. You can click on any of these to look at the source and http header information.
Unless the js code is using websockets, communication is likely just http:// on port 80.
if you use the developer console in chrome/safari, you can view all loaded javascript in the resources tab.
you can also use netstat to see what active port connections you have.

How to load javascript not present in localhost domain in chrome?

I am running a tomcat server and my localhost base domain is :
C:/apache/webapps/ROOT/
My webpage is also present here.
However the javascripts are present in an external location.
D:/something/something
And i am importing them the following way
<script src="D:/something/something/js1.js"></script>
In IE the page loads fine and able to locate the scripts, however with chrome it fails.
On debugging I see that chrome tries to append the following:
http://localhost:8080/D:/something/something
How do i get it to work on chrome without copying the scripts to base location?
For doing anything useful from within the JS code, you'll most likely have to obey the same origin policy. This means you'll have to configure your Tomcat so that it serves the scripts, too.
If you really insist on reading the scripts from local files, that's what file:// URLs do.
You can't do this because you will search for D:/something/something/js1.js in the user/client computer.
You can do it calling (read and print) the file via PHP (D:/something/something/js1.js.php) or any other server side programming language or installing a webserver in your external location to call the file via URL like myCDN.mydomain.com.
EDIT: If you will only work in localhost, use #Pointy and #Konstantin K solutions :)

Javascript not working on localhost, but it is working on Live site

I am facing JavaScript problems on XAMPP Localhost. The Collapse Buttons, go to top button and jQuery news feed are not working on every site on my localhost.
But Facebook, Twitter, Plusone buttons load correctly from remote server i.e. from the respective Social Sites.
So, I think it narrows me to the point that the JavaScript files hosted locally are not executed while those from Facebook etc. are getting executed.
I tried reinstalling XAMPP but didn't work.
I know this is old but, I had the same problem and found this question while searching a solution. But I have lampp installed on ubuntu and since Linux asks permission to execute ANYTHING, the local js files which resided in htdocs were without permission. After:
sudo chmod 777 -R /opt/lampp/htdocs
... everything was OK. Hope this helps future wanabee web developers.
It should not matter whether your files are local or not...javascript should still get executed. Try using some debugging tool like to see if you get any errors that only occur on your local machine. Because it could be that you are running some code that is depending on a domain or whatever.
I know this post is old and the answer is already given, I just wanted to give an answer of a possible reason that I encountered in case someone else finds this and it does not help.
Make sure your entire html code gets executed by viewing your page source. With me, half my code was not being executed due to a PHP error that was working on localhost with the local database but not on live with the live database. This caused the HTML to cut of from that point above my javascript.
So check your page source. If it is being cut of somewhere, find out why :)
I had the same problem. I try a lot but finally solved. The main problem was my browser cache that prevents from loading the new JavaScript file. My recommendation is that clear your browser cache data then close the browser and reopen your site again it will work perfectly.
remove any (pre in post ) blank spaces from filenames of your namespace example : localhost:port/dir /index.html
localhost:port/dir/index.html
In similar cases,
If web project site runs JS on Live Server but not on locally opened index.html,
try to check validity of HTML File Paths,
e.g you may have written:
<script src="script.js"></script>
instead of:
<script src="./script.js"></script>
Try to add ./ before file name.
./ means Current directory.

Categories

Resources