none
JavaScript errors with Client Web Part with Office Developer Tools Preview 2

    Question

  • I have not had any luck with building a Client Web Part since Preview 2 of the Office Developer Tools for Visual Studio 2012 came out.  I had no issue in Preview 1.  The issue I have is if I create a new Client Web Part, out of the box, I get the following error: 

    'decodeURIComponent' is undefined

    It seems like there should be a reference to jQuery like I did in the earlier preview.  If I add it to the page, I then get the following error instead.  I have even tried using the previous version of jQuery from Preview 1 and it doesn't work and I get the following error:

     'Object' is undefined

    In the meantime, I have gone back to building Client Web Parts with Preview 1 and Beta 2 of SP2013.  I'd really like to get this working.


    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth

    Monday, December 10, 2012 4:41 AM
    Answerer

Answers

  • This only occurs with IE9. We are aware of this problem and are investigating for the root cause. At the same time, if you use IE 8 or IE 10, the app part should work without this problem.
    Tuesday, December 18, 2012 8:42 PM

All replies

  • I've pinged our VS folks. Will get back to you shortly

    Program Manager, Office Developer Platform.


    Tuesday, December 11, 2012 12:17 AM
    Moderator
  • Do you still get the same error after Visual Studio is restarted? If so, can you try this on a different machine?

    decodeURIComponent is a common function in JavaScript. It should not be related to JQuery reference at all.

    Tuesday, December 11, 2012 3:58 PM
  • I've tried it in multiple projects and I always get it.  I haven't tried another VM yet, but I will.  It seems that any JavaScript fails because if I add the jQuery reference it fails there.  If I add a reference to MicrosoftAjax.js, I get errors in there as well.  I supposed it could be an issue with my tenant or this particular VM.  I did have Preview 1 installed on it originally and I removed it.

    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth

    Tuesday, December 11, 2012 4:06 PM
    Answerer
  • Update:  I restarted Visual Studio and I also tried deploying the app locally to an on-premises tenant where I see the same behavior.  The JavaScript inside default.aspx works fine too, just not in the App Part.

    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth

    Tuesday, December 11, 2012 4:24 PM
    Answerer
  • Can you zip-up a small project that reproduces the problem and share it somewhere? Does the problem occur at runtime after the app is deployed or at debugging time when you F5 the project?

    Tuesday, December 11, 2012 5:15 PM
  • No problem.  I've posted it to SkyDrive at the link below.  I've only tried it while debugging.  My local environment isn't configured to host apps without debugging through Visual Studio.  I could try manually uploading it to my SPO tenant though.

    http://sdrv.ms/US0eHw

    Thanks,
    Corey


    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth

    Tuesday, December 11, 2012 5:29 PM
    Answerer
  • It is pretty much a project with default contents. I tried it on a local on-prem SharePoint server and also the Office 365 site. It both worked without any errors.

    Is your on-prem SharePoint server 2013 RTM? Can you F5 your project against an SPO tenant?

    Tuesday, December 11, 2012 7:07 PM
  • That is strange.  Yeah there is nothing special to the project.  I can use F5 with on-prem or my SPO tenant.  It deploys fine.  The rest of the pages in the app work fine, but the Client Web Parts do not.

    Yes, the on-prem is RTM.  The only thing I can think of is that I used preview 1 and some other builds in between that might have messed things up.  Before, I started though I uninstalled the components and reinstalled with WPI 4.0.


    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth

    Tuesday, December 11, 2012 7:11 PM
    Answerer
  • When exactly do you get the error? Did you get it when you add the app part to a site page? It should not have anything to do with Preview 1, but may be related to your local IE.

    You can deploy the app to SPO and then check out the app from a different machine.

    Tuesday, December 11, 2012 7:19 PM
  • After a bit more testing, here is what I am seeing.  The JavaScript errors are getting caught in the debugger when I have Visual Studio attached.  The errors only occur the page is in edit mode.  Specifically, they occur when adding the app part to the page or while later editing the page again.  They don't seem to occur when running the page normally outside of edit mode.

    I've attached a screenshot so you can see what I mean.

    Client Web Part JavaScript Error Preview 2

    I can work around this, but it's odd behavior.  I never saw these issues running beta 2 and preview 1.  Thanks again for all your help.


    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth

    Tuesday, December 11, 2012 8:09 PM
    Answerer
  • One more follow-up.  If I add the app part from a different machine while the debugger is attached, no errors occur.   However, that is as expected since Visual Studio is on another machine.  My real question is, can I get those errors to go away to simplify my development process.  I have tried various settings in IE including adding the URL to the proxy exceptions list as described in the preparing your development environment for apps article.

    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth

    Tuesday, December 11, 2012 8:18 PM
    Answerer
  • I'm with Mr. Roth on this issue.  Created an app, added a client web part, hit F5 - same JS error.  No custom code added.  App works fine on F5, but trying to edit a page and adding the App Part throws the error.

    Thursday, December 13, 2012 4:21 PM
  • Good to know it's not just me then.  Thanks!

    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth | SP2 Apps

    Thursday, December 13, 2012 4:22 PM
    Answerer
  • Glad I could back you up...

    To add even more to the puzzle, if I add a reference to any js files, such as jquery or a custom js, I get errors galore, starting with:

    Unhandled exception at line 2, column 6859 in http://app-970ac45cdbb69d.apps.wingtip.com/StockTickerAppWithPart/Scripts/jquery-1.7.1.min.js

    0x800a1391 - Microsoft JScript runtime error: 'Object' is undefined

    Seems odd to be getting these errors in a stock jquery file.  This happens in the minimized and the full jquery js.  Everything in the aspx is standard, as shown below.

    <%@ Page language="C#" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    
    <WebPartPages:AllowFraming ID="AllowFraming" runat="server" />
    
    <html>
    <head>
        <title></title>
        <script src="../Scripts/jquery-1.7.1.min.js"></script>
        <script src="../Scripts/StockTickerAppPart.js"></script>
        <script type="text/javascript">
          
        </script>
    </head>
    <body>
        <h2>RUFKM</h2>
        <div id="message"></div>
    </body>
    </html>
    

    This is from following Corey's guide on dotnetmafia.  I'm stuck where I essentially can't do a SharePoint hosted Client Web Part because of these JavaScript issues.


    Thursday, December 13, 2012 4:51 PM
  • I get the exact same Object is undefined error.  As I mentioned above though, it seems to only occur when the page is in edit mode.  If I hit continue in Visual Studio 5 or 6 times, eventually the web part will get added.  Then once I am out of edit mode, I can test my app.  

    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth | SP2 Apps

    Thursday, December 13, 2012 4:53 PM
    Answerer
  • Alright, so I'll amend mine - I was not able to test my app, even out of edit mode - still throwing numerous JS errors.  In a fit of curiosity and experimentation, I added a reference to the MicrosoftAjax library that you reference in your guide.  Now I am at least in the same boat as you, where I can test if I get out of edit mode.  I was running under the assumption that the MicrosoftAjax.js library was not required.

     

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

    Thursday, December 13, 2012 6:56 PM
  • I really didn't think it was but I got it from some examples during Preview 1 and got in the habit of including it.  I guess maybe it is necessary.

    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth | SP2 Apps

    Thursday, December 13, 2012 6:58 PM
    Answerer
  • Did anyone find any answers or workarounds to this? I am in the same boat as Corey and Matt. Everytime I go into edit mode with a Client WebPart (during debugging) I get all kinds of Javascript errors from jQuery and the Microsoft Ajax javascript files. The second I am out of edit mode everything is fine. The issue is, every time I tweak my code and redeploy I have to re-add the webpart to the screen and that makes me go into edit mode. It's really time consuming to do development like this.

    Anyways, it looks like a bug in SharePoint. So, I am wondering if anyone found a workaround to not have to go into edit-mode everytime? Has anyone figured out how to get the Client Web part to stay in the zone? Seems that everytime I hit F5 if makes me start over and add it every time. If I could figure out a way to stop that from happening this bug wouldn't be so annoying.

    Sunday, December 16, 2012 5:24 PM
  • Hi all.  I found a work-around for this that makes this issue slightly less painful.  Start debugging as usual.  Then open a separate browser window, add the web part, and then save the page.  This other browser window isn't attached to the debugger so the errors won't occur.  At that point, you can go back to the browser window attached to the debugger and work with your App Part should you need to debug.

    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth | SP2 Apps

    Monday, December 17, 2012 6:40 PM
    Answerer
  • This only occurs with IE9. We are aware of this problem and are investigating for the root cause. At the same time, if you use IE 8 or IE 10, the app part should work without this problem.
    Tuesday, December 18, 2012 8:42 PM
  • I can confirm that I was using IE9.  I installed IE10 Release Preview on the VM and the issue has now been resolved.  This is an acceptable work-around for me.  I'll mark the thread as answered.

    Corey Roth - SharePoint Server MVP blog: www.dotnetmafia.com twitter: @coreyroth | SP2 Apps

    Tuesday, December 18, 2012 9:20 PM
    Answerer
  • I have the same problem in IE9. I am happy to hear that I am not alone :)
    Thursday, February 7, 2013 7:22 PM
  • Still no fix for this problem? Keeps happening to me :-(
    Wednesday, February 13, 2013 9:31 AM
  • Still no fix for this problem? Keeps happening to me :-(
    I started getting this problem after I installed java VM on my machine. My current java version is Version 7 Update 17.
    Thursday, March 21, 2013 4:52 AM