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

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()

Related

Google JSAPI Breaking Requirejs

I shall start by creating a list of the order my scripts are loaded in:
<script src="/shared/js/requirejs/require.js" type="text/javascript"></script>
<script src="/js/main.js" type="text/javascript"></script>
<script src="https://www.google.com/jsapi" type="text/javascript"></script>
After that I have a file that looks like this:
<script type="text/javascript">
google.load("visualization", "1", {packages:["bar","line"]}); <--- this breaks everything
require(['jquery','moment','underscore','validate','serializeObject','datepicker'],function($,moment,_){
// Do stuff in here
});
</script>
Does anyone have any clue as to why google.load(); causes my page to break?
Sometimes it throws "Object doesn't support property or method 'extend' (require.js)"?
Sometimes it acts like validate or underscore has not been loaded when it gets to parts of my code that use them.
Other times, the page loads just fine and works.

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>

Cannot get access to Marionette module from app.js

I am currently working my way through David Sulc's excellent "Backbone.Marionette.js: A Gentle Introduction" and have come unstuck at modules. With the app as it currently stands I am trying to access an API in a module called 'contacts.js' from the index.html script but I get the following error when I try to run the app:
"Handler not found for 'contact: entities' "
I am able to hit the API directly from the console in Chrome and manually get the 'contact' information so I was thinking this was a loading sequence problem where the API might not be available by the time app.js loads, however the loading sequence is as follows:
<script type="text/javascript" src="assets/js/vendor/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="assets/js/vendor/json2.js"></script>
<script type="text/javascript" src="assets/js/vendor/underscore-min.js"></script>
<script type="text/javascript" src="assets/js/vendor/backbone-min.js"></script>
<script type="text/javascript" src="assets/js/vendor/backbone.marionette.min.js"></script>
then the local scripts as follows:
<script type="text/javascript" src="assets/js/app.js"></script>
<script type="text/javascript" src="assets/js/entities/contact.js"></script>
and a script tag below the last two script tags directly runs the following code:
<script type="text/javascript">
... some view code
ContactManager.on("initialize:after", function(){
var contacts = ContactManager.request("contact: entities");
... some more code
</script>
the line beginning var contacts = ..... is the one giving me the error. Any help appreciated
I am as certain as I can be that I have scripted this exactly as per the book.
You have a space in your event name:
<script type="text/javascript">
... some view code
ContactManager.on("initialize:after", function(){
// Remove the space in contact: entities -->
var contacts = ContactManager.request("contact: entities");
... some more code
</script>

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

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>

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