6

I'm just starting with SharePoint 2013 dev. I've created a VM on my computer, it's running Windows Server 2013 and SharePoint 2013 Foundation.

I'm trying to create a App with a App part in it. On VS 2012 I've created a new project based on the template "App for SharePoint 2013". I'm choosing to host it as Sharepoint-Hosted.

When i deploy this basic App, everything runs normally. I go back to Visual Studio and add a Client Web Part to my project, i don't change anything in it's code and deploy it.

When i add this App Part to any page i've created, my Visual Studio returns a exception saying:

0x800a1391 - JavaScript runtime error: 'Type' is undefined in the sp.runtime.js

I've done a little search about this subject and came across this post http://blogs.msdn.com/b/officeapps/archive/2012/09/04/using-the-javascript-object-model-jsom-in-apps-for-sharepoint.aspx

One of the comments says:

"This error is usually fixed by adding the reference to MicrosoftAjax:

<script type="text/javascript" src="/ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"</script>"

I tried that, replaced the default code of the web part:

<script type="text/javascript" src="/_layouts/15/MicrosoftAjax.js"></script>

for the code he mentioned

<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script>

The web part won't give me an error anymore, but i'm thinking wasn't it supposed to work with the default MicrosoftAjax that's in the /_layouts/ folder? What if the server i'm going to deploy my app for some reason can't access the URL to get the .js file?

Anyone else had this error and knows how it's fixed?

2

What if the server i'm going to deploy my app for some reason can't access the URL to get the .js file?

Following code:

<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script>

... is the client-side part of code, so you don't have to bother that server you are going to deploy your app for some reason can't access the URL to get the .js file.

  • Isn't this exactly where the problem wil be if the server has no internet connectivity? – Robert Lindgren Sep 18 '13 at 10:26
-1

try to change the order in which you reference the scripts.. keep jquery reference on top

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.