Showstopper - AJAX Issues RRS feed

  • Question

  • I am slightly dissapointed with the AJAX issues I'm running into when trying to build office content pane apps. For example, a simple jQuery.load to load myapp/page2.html returns "No Transport" error. I tried to fix this by forcing jQuery to only use the XHR object as opposed to the activeX (as suggested in another forum post), but then the error is "Access is Denied".

    Next, I decided to wire up a web-api controller with CORS support enabled. (This method has worked for me on other projects to get around cross domain restrictions). Of course, I set jQuery.support.cors = true; in the js code. I ran a test call and no luck.

    I get out-of the-box support for jQuery load and web-api calls when I run the app from Visual Studio. However, when I install the app and run it from my local network, the jQuery calls/web-api calls do not execute.

    Navigating to myapp/page2.html is clearly NOT a cross-domain call, so what is the problem? Where is my incentive to build office apps if I cant even get same-domain ajax navigation calls to work? Please do not point me to the workaround for CORS because I have already done it. Also, we are talking about same-domain jQuery ajax navigation, so CORS should not be an issue.

    I have some innovative ideas for apps, but this issue is a showstopper. 

    • Edited by Appeality Tuesday, March 26, 2013 10:06 PM
    Tuesday, March 26, 2013 10:05 PM

All replies

  • Hi

    To start with something you might not like: setting "jQuery.support.cors = true;" is something one should never do, since "jQuery.support.cors" is a property that tells you (or jquery ajax method) if cors is supported. So unless you write a plugin that adds a cors support to (this) browser you sohuld never change it (changing it to true does not resolve any cors problems browser might have).

    If you think it might be a cors problem, then the best way to eliminate it, is to use "dataType: 'jsonp'" in your ajax calls (this is a bullet proof cross domain resolver).

    If setting to jsonp will not solve your issue, then its definitly not a cross domain problem. Open developer tools (F12) and open networking tab and click start capturing. Click the button that does the call and look at the network traffic.

    Providing additional code of your problem would also be appritiated so i can help more.

    Anze Javornik

    Wednesday, March 27, 2013 7:26 AM
  • I only set jQuery.support.cors to "true" after I tested on a .net web api project, which was configured to accept cross domain requests. Once this did not work, I really knew there was an issue.

    Simply setting jsonp will not work if the server is not configured to return jsonp. Besides, I am simply making same-domain-calls. F12 does not show anything becasuse the content pane app will not fire the ajax call. I configured the app to show errors within the app itself and I keep getting either "no transport" [with default jquery settings] or "access denied"

    Furthermore, when I run from Visual Studio all calls work fine. I'm sure I'm not the only one with this problem.

    //Wire up nav test
    function wireUpNav() {
        $("#lbLoadNextPage").click(function () {
            $("#active").load('secondPage.html', function (response, status, xhr) {
                if (status == "error") {
                    var msg = "Error occured: ";
                    write(msg + xhr.status + " " + xhr.statusText);

    Here is a simple, same-domain ajax call to load data from PAGE2 and insert it into the container with id ACTIVE. The app will not execute this call when inserted. However, it works when launched from Visual Studio. 
    • Edited by Appeality Wednesday, March 27, 2013 4:20 PM
    Wednesday, March 27, 2013 4:16 PM
  • I have similar issue with AJAX in a very simple Mail App I use as a prototype. For the testing environment I am using Office 365 Preview environment.
    I thought the problem was solved when cors was enabled on the web services location but the behavior is inconsistent.

    On a good day everything works fine, sometimes I get complains about certificate, but very often it doesn’t work - I get error “Access is denied”. I am using hardcoded credentials and service url so there is no doubt about wrongly entered details.

    Next to that I had issues with caching script/page so I created new project (VS has a new layout for Apps again!) and now I can’t remove old App that was earlier deployed from VS with debugger.

    I have never before had so many issues with such a tiny piece of code and I wonder if using AJAX (for cross domain) calls is recognized as issue in Office Apps.

    Despite mentioned issues I still think that Office Apps are great improvement for Office!

    Friday, March 29, 2013 12:12 PM
  • Did you manage to fix this problem, found a workaround or made any progress? Or is this issue still open...if so can you please provide some more details on how far have you gotten?

    Anze Javornik

    Monday, April 29, 2013 10:56 PM
  • Hi Anze,

    Thanks for asking but I didn’t look any further how to resolve the issues mentioned above as I want to discuss this at one of the Office/SharePoint Dev events I plan to join soon.


    Thursday, May 2, 2013 8:43 AM