I am following a video on LinkedIn learning, and when I try to run my code, I get the following error: Uncaught SyntaxError: Unexpected token '<' and I have looked at the files and don't see this '<' on line 1 as the error says. This error results in a fix for a Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec. where I added type="text/javascript" in front of the src. Line 1 of the first file I get the error for is /******/ (function(modules) { // webpackBootstrap and as you can see there is no < in that line. Any help is greatly appreciated.
EDIT: Here is the code in question:
<script src="runtime-es5.js" nomodule defer></script>
<script src="polyfills-es5.js" nomodule defer></script>
<script type="text/javascript" src="polyfills-es2015.js" type="module"></script>
<script type="text/javascript" src="styles-es2015.js" type="module"></script>
<script src="styles-es5.js" nomodule defer></script>
<script type="text/javascript" src="vendor-es2015.js" type="module"></script>
<script src="vendor-es5.js" nomodule defer></script>
<script type="text/javascript" src="main-es2015.js" type="module"></script>
<script src="main-es5.js" nomodule defer></script>```
any of the scripts with type="module" are the issues.
Sounds like you are making an HTTP request and it is returning the entire webpage instead of the data you are looking for because of an error in the request. So the first character in the response is < which is part of the <!DOCTYPE html> at the top of the html file that is coming back in the response. If you show us a sample of your code that is making this request I could be more specific.
Related
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()
I'm getting untermined string literal errors when I load resources like:
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
And while debugging console actually says this error is on those lines where I put these scripts.
I am simply trying to show 3 diagrams, nothing more. The problem I am encountering is that the whole page turns white when I include the javascript files that belongs to the diagram number 2 and 3. How can I prevent this conflict, any ideas?
Error code I receive in console:
uncaught exception: Highcharts error #16:
www.highcharts.com/errors/16
SyntaxError: expected expression, got '<'
ExhaustTemperature.js $(...).highcharts is not a function
Here is the library for diagram 1.
<script src="highcharts.js"></script>
<script src="highcharts-more.js"></script>
Here is the library for diagram 2 and 3.
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
Then the funny part... The whole page turns white when I include these two javascript files.
<script src="diagram2.js"></script>
<script src="diagram3.js"></script>
This is what it looks like in index.html file.
<script src="highcharts.js"></script>
<script src="highcharts-more.js"></script>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
<script src="diagram2.js"></script>
<script src="diagram3.js"></script>
When I use moment.min.js, chrome/FireFox gave me such error"Uncaught SyntaxError: Unexpected end of input moment.min.js:7"
Here is pieces of .html:
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/js/headroom.min.js"></script>
<script src="/static/js/jQuery.headroom.min.js"></script>
<script src="/static/js/template.js"></script>
<script src="/static/js/moment.min.js"></script>
<script src="/static/js/bootstrap-datetimepicker.min.js"></script>
I tried version 2.6 and 2.8.4 2.8.3, but met the same error.
It be hard to diagnose the problem with that little of information... However most likely the error being cause from a conflicting script(s) which were loaded before it was.
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>