Issue to load The Microsoft Ajax Content Delivery Network (CDN) - ajax

I am wonder why when use Microsoft CDN it cause problems in my site.
for example when I use :
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
then my page has problem to validate the data each time I am facing with new issue...
but when I load the those js file from local as below, there is no any problem.
<script src="#Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
So what is wrong with that ?

Related

MicrosoftAjax.js is not loaded successfully in word web add in

I am building a word web add-in with VS2015 and pretty much randomly (I don't change anything, then get this new error) office.js will crash with the error
0x800a139e - JavaScript runtime error: MicrosoftAjax.js is not loaded successfully.
It is super frustrating because I cannot always repeat the error and the javascript engine afterwards completely crashes causing me to restart visual studio and reload the project (NOT fun when doing a live demo)
EDIT: attached html calling for officejs
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title></title>
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<link rel="stylesheet" href="https://appsforoffice.microsoft.com/fabric/1.0/fabric.min.css">
<link rel="stylesheet" href="https://appsforoffice.microsoft.com/fabric/1.0/fabric.components.min.css">
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" type="text/javascript"></script>
<!-- To enable offline debugging using a local reference to Office.js, use: -->
<!-- <script src="../../Scripts/Office/MicrosoftAjax.js" type="text/javascript"></script> -->
<!-- <script src="../../Scripts/Office/1/office.js" type="text/javascript"></script> -->
<link href="../App.css" rel="stylesheet" type="text/css" />
<script src="../App.js" type="text/javascript"></script>
<link href="Home.css" rel="stylesheet" type="text/css" />
<script src="Home.js" type="text/javascript"></script>
</head>
I know I am a little late on the answer, but I ran into the same issue. This microsoft dev article addresses and provides the solution to this issue.
https://dev.office.com/blogs/Office-Store-add-in-validation-changes-using-MicrosoftAjax-js
Basically the new office.js script in the html, that used to load microsoft ajax does not any longer since 2016. i.e.
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" type="text/javascript"></script>
Some functions like Excel.run were checking to make sure microsoft ajax was loaded and not working for me in an Excel add-in. The solution is to just load ajax yourself, or if not using ajax reference the microsoft dev announcement above and load a different office.js package the announcement provides.

Can Mathjax be used with https?

Can Mathjax be used with https?
This script renders latex if the page is called http:..., but not https:...
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&ver=3.5.1'>
</script>
Yes, see http://docs.mathjax.org/en/latest/start.html#mathjax-cdn. Use the script
<script type="text/javascript"
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

Kendo JS Dependency not working for Grid

Actually i used to bind my data-source using kendo Grid.
I checked kendo.all.min.js is working fine but i dont want unwanted js files while loading so include the Grid dependency files in my code but it does not works...
It shows an error in console. This is my js
<script src="#Href("~/Scripts/libs/kendo.grid.min.js")" type="text/javascript"></script>
<script src="#Href("~/Scripts/libs/kendo.core.min.js")" type="text/javascript"></script>
<script src="#Href("~/Scripts/libs/kendo.data.min.js")" type="text/javascript"></script>
The files are not included in the right order. For example kendo.core.js should be first. Here is the documentation which lists the proper order of dependencies: http://docs.kendoui.com/getting-started/javascript-dependencies#grid
<script src="/Scripts/kendo/2012.2.710/kendo.web.min.js"></script>
<script src="/Scripts/kendo/2012.2.710/kendo.core.min.js"></script>
<script src="/Scripts/kendo/2012.2.710/kendo.data.min.js"></script>
<script src="/Scripts/kendo/2012.2.710/kendo.grid.min.js"></script>
Put like this it's working...

One jQuery conflict left, after using NoConflict with prototype in files

I am having a problem with a new OpenCart site I am building...
I spliced a Html theme with an opencart theme.... The Html theme uses prototype as a library and OpenCart uses the jQuery library. So I went in and used: jQuery.noConflict(); in all my OpenCart files that use the jQuery library (which is all OpenCart JS)
It fixed everything on my site except this: http://beta.justicejewelers.com/index.php?route=product/category&path=79 - If you click on "add to cart" from this screen its fine... However if you click "add to cart" on the sample product 1 for example its going to take you to the product page to select a size.... hit add to cart there and nothing happens.... Also happens to products without options....
Any ideas?
Also here is what I am calling in the header:
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
<script type="text/javascript" src="js/prototype.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write(unescape('%3Cscript src="catalog/view/theme/sellegance/js/jquery-1.7.1.min.js"%3E%3C/script%3E'))</script>
<script src="catalog/view/theme/sellegance/js/modernizr.full.min.js"></script>
<script type="text/javascript" src="catalog/view/javascript/jquery/ui/jquery-ui-1.8.16.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="catalog/view/javascript/jquery/ui/themes/ui-lightness/jquery-ui-1.8.16.custom.css" />
<script type="text/javascript" src="catalog/view/javascript/jquery/colorbox/jquery.colorbox.js"></script>
<script type="text/javascript" src="catalog/view/theme/sellegance/js/jquery.elastislide.js"></script>
<script type="text/javascript" src="catalog/view/theme/sellegance/js/jquery.cycle.js"></script>
<!-- NEW SCRIPTS -->
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/banner_pack.js"></script>
<script type="text/javascript" src="js/jquery.jcarousel.min.js"></script>
<script type="text/javascript" src="js/jquery.mix.js"></script>
<script type="text/javascript" src="js/menu.js"></script>
TypeError: Cannot call method 'after' of null [http://beta.justicejewelers.com/index.php?route=product/product&product_id=50:1111]
At the line 1111:
$('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');
replace $ with jQuery.
P.S. You should invoke jQuery.noConflict() only once after jquery is included.
P.P.S. Include your CSS files before any JS files - this will speedup page loading.

Unobtrusive Validation Not Fired

I have a MVC3 view, local debug perfectly fine, after I deployed to server I found unobtrusive validation is not fired at all.
I saved the output to a static HTML file and get rid all unnecessary codes and with following section remaining
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
Dummy
</title>
<link type="text/css" href="/Content/site.css" rel="stylesheet" />
<script type="text/javascript" src="/Scripts/jquery-1.6.4.js"></script>
<script type="text/javascript" src="/Scripts/jquery.validate.js"></script>
<script type="text/javascript" src="/Scripts/jquery.validate.unobtrusive.js"></script>
<script type="text/javascript" src="/Scripts/jquery.unobtrusive-ajax.js"></script>
</head>
<body>
<form action="/Test/Dummy" data-ajax="true" data-ajax-complete="MyDummy.OnComplete" data-ajax-method="Post" id="form0" method="post">
<select data-val="true" data-val-number="The field SourceId must be a number." data-val-required="SourceId required." id="SourceId" name="SourceId"></select>
<span class="field-validation-valid" data-valmsg-for="SourceId" data-valmsg-replace="true"></span><br />
<select data-val="true" data-val-number="The field DestinationId must be a number." data-val-required="DestinationId required." id="DestinationId" name="DestinationId"></select>
<span class="field-validation-valid" data-valmsg-for="DestinationId" data-valmsg-replace="true"></span><br />
<input type="submit" value=" Submit " class="ButtonStyle" />
</form>
<script type="text/javascript">
var MyDummy = {
OnComplete: function (content) {
alert(content.responseText);
}
}
</script>
</body>
</html>
I believe I have included proper JavaScript files, all the rendered Html looks fine to me. When I click on the submit button I expect validation message, but instead the oncomplete event fires.
I am very lost here, anybody has clue what is wrong?
Edit 1, I copied the same static Html file to my local project's folder and access it via http://localhost:48194/test.htm (my local ASP.NET Development Server) and everything works fine. But if I load the same file from 2008 server's local IE8 at http://localhost:87/test.htm (IIS 7) then I got the issue. Somehow it leads me to think is there something wrong setting IIS7 which blocks or partially blocks the access to JavaScript files properly?
Edit 2,
If I change the JS reference to use CDN like
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.4.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.unobtrusive-ajax.js"></script>
Then it works. I really don't know now what IIS7 could do to damage the local JS file transportation.
I does sound like IIS blocks the javascript.
In IIS you can set filters for which files are allowed or denied. Maybe for some reason someone (accidentally) blocked .js? - Another issue could be file access. IIS normally runs under a different user, so maybe it does not have access?
But I'm kind of just guessing. So the easiest way to test this is to just visit the .js file directly. So just open your http://localhost:87/Scripts/jquery-1.6.4.js and check what IIS returns. Maybe it returns a 403 error, maybe something else, at least it'll probably help to figure out what's wrong.
#section Scripts
{
<script src="../Scripts/jquery.validate-vsdoc.js"></script>
<script src="../Scripts/jquery.validate.js"></script>
<script src="../Scripts/jquery.validate.min.js"></script>
<script src="../Scripts/jquery.validate.unobtrusive.js"></script>
<script src="../Scripts/jquery.validate.unobtrusive.min.js"></script>
}

Resources