JavaScript runtime error: 'NotifyScriptLoadedAndExecuteWaitingJobs' is undefined
Posted
Monday, April 29, 2013 9:57 PM
by
CoreyRoth
I recently ran into the following error when working with a SharePoint 2013 Client Web Part (App Part) while accessing the term store using SP.Taxonomy.js.
JavaScript runtime error: 'NotifyScriptLoadedAndExecuteWaitingJobs' is undefined.
The following line gets hit in the debugger.
The code I had worked fine inside a page, but when placed inside a client web part, I received the error. I thought it might be something to do with the order in how I loaded the script files. I recently switched to the new Client Web Parts set up in the RTM version of the Office Developer Tools. This particular update changes the references to the JavaScript files to the page instead of being loaded dynamically with $.GetScript(). It turns out it had nothing to do with that. Instead, I just needed to add a reference to Init.js. Here is what my complete list of references looks like in the page for my client web part.
<script type="text/javascript" src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/_layouts/15/MicrosoftAjax.js"></script>
<script type="text/javascript" src="/_layouts/15/init.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.taxonomy.js"></script>
If you receive the error above that is all you have to do.. Luckily, it’s easy to fix.