locked
AJAX call is not working in Office Addins JS RRS feed

  • General discussion

  • I am trying to get data using WebAPI with below code but not getting data while add Office Addin in word document.

    code is running fine and correct in solution, but not working while use it to local word ( add ins load correctly without getting this data) 

    Please guide me what i have to do if i want to get data from service and for what i have to do for AJAX call.

    using below code : 

    myUrl = '../../api/Values/GetSectionList/';

    var objService = {};
    var objData = {};

    objData.id = id;
    objService.data = objData;
    var params = objService;

    $.ajax({

                            url: myUrl,
                            type: 'GET',
                            dataType: 'json',
                            contentType: 'application/json; charset=utf-8',
                            data: params.data,

    success: function (resp)

    {

    console.log(resp);

    },

    failure: function (resp)

    {

         console.log(resp);
    }

    });

    • Edited by Sohel Vali Monday, March 14, 2016 9:17 AM
    Friday, March 11, 2016 11:52 AM

All replies

  • Did you ever find a solution to this?  I am having the same problem and believe it is some kind of security feature in MS Word.  I am getting an "Access Denied" error when I try to use it.  Can't figure out how to tell Word that the URL is safe to use.

    Graham

    Sunday, February 5, 2017 6:04 PM
  • I found the answer!

    The problem is related to scripting across different Domains.  I found 2 solutions.

    1.  Use https when making the ajax call.

    2.  Disable SSL requirement in the Projects Properties by setting SSL Enabled to False.  (see attached pic)

    Monday, February 6, 2017 2:59 PM
  • Where is the attached picture? I am having so much trouble with this...
    Wednesday, February 15, 2017 8:27 AM