Monday 8 June 2015

Sharepoint 2013 App 'Type' is undefined

While doing sharepoint 2013 app development I came across some error. It was throwing error on the line
Type.registerNamespace("SP");
while checked using the developer tool. This issue can be addressed by adding Microsoftajax.js reference to your app page. The reference to be added is

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

The order in which the refernce should be is

<script src="jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script>
<script src="_layouts/15/sp.runtime.js" type="text/javascript"></script>
<script src="_layouts/15/sp.js" type="text/javascript"></script>