java scripts on my website running locally but not running on server - javascript

I have a designed a website and included some java scripts, they run perfectly locally but on uploading to the server, nothing works!! I tried changing the reference to the pages to //http: but still...nothing. I've tried testing on the server with a simple alert text box,it works. I don't understand why the other .js scripts aren't working. please Help.
<script type="text/javascript">
var shutterSettings = {"msgLoading":"L O A D I N G","msgClose":"Click to Close","imageCount":"1"};
</script>
<script src='http://www.broadigital.co.ke/style/newcss/js/shutter-reloaded.js?ver=1.3.3' type='text/javascript' ></script>
<script src='http://www.broadigital.co.ke/style/newcss/js/jquery.js?ver=1.7.2' type='text/javascript' ></script>
<script src='http://www.broadigital.co.ke/style/newcss/js/jquery.cycle.all.min.js?ver=2.9995' type='text/javascript' ></script>
<script src='http://www.broadigital.co.ke/style/newcss/js/ngg.slideshow.min.js?ver=1.06' type='text/javascript' ></script>
<script src='http://www.broadigital.co.ke/style/newcss/js/jquery.flexslider-min.js?ver=3.4.2' type='text/javascript' ></script>

Uncaught SyntaxError: Unexpected end of input jquery.js:6
Uncaught ReferenceError: jQuery is not defined
Check if you uploaded jQuery correctly. The file might have been truncated in the process.
UPDATE
Checking your jQuery file, the file truncates on line 6 with these as the last few characters.
if(this[0]){var b=f(a,this[0].owne
SOLUTION
Re-upload the jQuery file (jquery.js) again, or
Use jQuery CDN:
Change:
<script src='http://www.broadigital.co.ke/style/newcss/js/jquery.js?ver=1.7.2' type='text/javascript'></script>
To:
<script src='http://code.jquery.com/jquery-1.7.2.min.js' type='text/javascript'></script>

Related

javaScript runtime error: Expected ':' on the url provided

i have a project which is written in MVC3,its a signalR,i got the code to edit some part but i see its gives an error,on the following part which says cant start a null refrence:
$.connection.hub.start().done(FUNCTION....)
meaninf the valu of hub is null,the fowlooing are the scripts which are loading:
<script src="#Url.Content("~/Scripts/jquery-1.7.2.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/leitwind/dateExtension.min.js?ver=1")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/knockout-3.0.0.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/knockout.mapping-latest.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/leitwind/knockoutAutoRefresh.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/DataTables-1.9.2/media/js/jquery.dataTables.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.signalR-0.5.2.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/signalr/hubs")"></script>
when i go to the developer option of the browser its showing the error on the last refrence,signalr/hubs which does not exist!im wondering why the project is running on the server but not on the local pc even thought i have the same scripts and anything has been changed,after one day of investigation i thought maybe i should give the address of the server instead of signalr/hubs,with this work around i that error is not threwing any more but i have the following issue,all in all i dont have any idea where i should look
is there something wrong with the url format?
i need to set the address manually in my code in order to get data from the server,for the follwoing part:
$.connection.hub.url ='https://myserver.com/file/signalr/';
$.connection.hub.start().done()

None of my JS files are getting loaded on localhost

I installed a local coldfusion server on my computer to as a development enviroment.
I created a basepath variable (if CGI.SERVER_NAME is localhost, then set the path to http://localhost:8500/ else set it to http://example.com).
For some reason none of my javascript is loading on the localhost. There is no error on the console. I look at the network and all the images and CSS are loading. I check the paths to the javascript files and they all seem to be working when I click through to them.
I'm a little lost as to what could be causing this. It is preventing me from developing on my development server.
Thank you
Edit: This the pre-processed code (inside the tag):
<!--- SCRIPTS --->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script>
<script src="<cfoutput>#app_basepath#</cfoutput>/js/jquery.customSelect.min.js"></script>
<script src="<cfoutput>#app_basepath#</cfoutput>/js/owl.carousel.min.js"></script>
<script src="<cfoutput>#app_basepath#</cfoutput>/js/jquery.fancybox.js"></script>
<script src="<cfoutput>#app_basepath#</cfoutput>/js/jquery-scrolltofixed-min.js"></script>
<script src="<cfoutput>#app_basepath#</cfoutput>/js/jquery.prettyPhoto.js"></script>
<script src="<cfoutput>#app_basepath#</cfoutput>/js/responsive.js"></script>
<script src="<cfoutput>#app_basepath#</cfoutput>/js/global.js"></script>
This is the processed code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script>
<script src="http://localhost:8500/example.com/js/jquery.customSelect.min.js"></script>
<script src="http://localhost:8500/example.com/js/owl.carousel.min.js"></script>
<script src="http://localhost:8500/example.com/js/jquery.fancybox.js"></script>
<script src="http://localhost:8500/example.com/js/jquery-scrolltofixed-min.js"></script>
<script src="http://localhost:8500/example.com/js/jquery.prettyPhoto.js"></script>
<script src="http://localhost:8500/example.com/js/responsive.js"></script>
<script src="http://localhost:8500/example.com/js/global.js"></script>
EDIT2: Ok, here is the code that sets the app_basepath variable
<cfif CGI.SERVER_NAME eq 'localhost'>
<CFPARAM name="variables.app_basepath" default="http://localhost:8500/example.com" >
<cfelse>
<CFPARAM name="variables.app_basepath" default="http://example.com" >
</cfif>
I don't think you need to do any of this for this need. I would suggest that you do not include the first part of the path.
Put your src like this :
<script src="js/jquery.customSelect.min.js"></script>
So this will work on your dev environnement and live as well, without changing anything on the server side.

Linking to files in custom 404 page not working in other directories

SO I have this 404 page
and I think I understand the problem.
SO this works correctly: sia.github.io/404.html and so does this:
sia.github.io/ooofdfsdfaablahblah
BUT sia.github.io/1/2/3/
does work, but all the files are missing, as in the jpg and all the .js scripts.
How do I link them so they work?
Like in a script you'd make this problem go away if you had an issue with
/Documents/fileIwant.txt
to
~/Documents/fileIwant.txt
so it would always go home first then get the file.
I see you 404 file code
<script src="js/Three.js"></script>
<script src="js/Detector.js"></script>
<script src="js/Stats.js"></script>
<script src="js/OrbitControls.js"></script>
<script src="js/THREEx.KeyboardState.js"></script>
<script src="js/THREEx.FullScreen.js"></script>
<script src="js/THREEx.WindowResize.js"></script>
When we access http://sia.github.io/ooofdfsdfaablahblah , The js/Three.js will location to http://sia.github.io/js/Three.js .
Howere if we access http://sia.github.io/1/2/3/ , The js/Three.js will location to http://sia.github.io/1/2/3/js/Three.js . this file not found.
solution one:
<script src="/js/Three.js"></script>
or solution two:
<base href="http://sia.github.io/" />
<script src="js/Three.js"></script>

cant get jquery to work with php file

I have a linux webserver that has /var/www configured in the Apache2.conf file as the DocumentRoot. Next I have my jquery core file located at /var/www/js/jQuery_v1.4.2.js (a central location for all my websites to access.
The .php index file is located at /var/www/AOI/aoiparse.php, where the aoifunctions.js file is also located. My <head> tag looks as follows:
<script type='text/javascript' scr='/js/jQuery_v1.4.2.js'></script>
<script type='text/javascript' scr='aoifunctions.js'></script>
my aoifunctions.js file has the following in it in order to verify that the script link works:
$(document).ready(function(){
alert("hello");
});
My problem is that I cannot get the alert() to work. I'm not getting an error message so I do not know where the problem is.
You can try <script type='text/javascript' src='../js/jQuery_v1.4.2.js'></script>
(The attribute is src, not scr, plus your path was incorrect)
put the jquery file in /var/www/AOI/js/ and then
remove the first /
<script type='text/javascript' src='js/jQuery_v1.4.2.js'></script>
so it lies in a subdirectory to your main page
or use this if you want to leave it where it is:
<script type='text/javascript' src='../js/jQuery_v1.4.2.js'></script>
You misspelled "src" in your <script> tags. It's short for SouRCe.
<script type='text/javascript' src='/js/jQuery_v1.4.2.js'></script>
<script type='text/javascript' src='aoifunctions.js'></script>
If you used Firebug you'd have been able to easily tell that the scripts weren't loaded.

Problem with RegisterClientScriptInclude and RegisterClientScriptBlock

I Have usercontrol and i registered the following javascript method in code behind :
changeSelectedMenu(controlID);
the previous method is declared in JScript.js file so i registered it also .
but the following exception has been thrown :
Microsoft JScript runtime error: Object expected
The result page is :
<script src="~/Scripts/JQuery.js" type="text/javascript"></script>
<script src="~/Scripts/JScript.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
changeSelectedMenu('ctl00_ctl00_cntMain_procedureContentHolder_procedureMenu_appointmentsLink');//]]>
</script>
Is There anyone can help me to workaround this issue???
These aren't valid paths to your JavaScript:
<script src="~/Scripts/JQuery.js" type="text/javascript"></script>
<script src="~/Scripts/JScript.js" type="text/javascript"></script>
They need to be relative to the page or to the site root, for example:
<script src="/Scripts/JQuery.js" type="text/javascript"></script>
<script src="/Scripts/JScript.js" type="text/javascript"></script>
While ~/ works for resolving a path on the server-side, the browser doesn't know how to handle this. There are some other work-arounds in this question for making it work and still being app-relative.

Categories