SharePoint Online: [Rest API & SharePoint App] How to access other web context

Required App permission to be setup in order to access the web, under AppManifest.xml

Example code snippet:

SP.AppContextSite is the core part to call from App to SharePoint

var hostweburl =

var appweburl =

//Example: Get List Item
function getItems (listName, queryText, rowLimit) {
     var d = $.Deferred();
     var viewXml = '<View><Query>' + queryText + '</Query></View>';
     var query = {
         'query': {
            '__metadata': { 'type': 'SP.CamlQuery' },
            'ViewXml': viewXml
     //default limit
     var limit = 10;
     if (rowLimit)
        limit = rowLimit;
     var settings = {
        url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists/GetByTitle('" + listName + "')/items?@target='" + hostweburl + "'&$top=" + limit,
        contentType: "application/json;odata=verbose",
        type: "GET",
        headers: {
            "accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val()
        success: function (data) {                                                
        error: function (data) {

      if (queryText) {
        settings["data"] = JSON.stringify(query);


      return d.promise();

WCF & AJAX: My submitted changes does not update in IE but on other browsers

My view doesn’t get updated when I submitted data through WCF service in IE with jQuery $.getJSON, $.ajax, etc…

But it works in chrome, Firefox, etc…


Because by default in IE, all the service request will get cached in the browser.


We need to force the browser to not to do any caching on with ajax call in jQuery

  1. To do it globally, add the following line when document ready, $.ajaxSetup({ cache: false });
  2. To do it specifically within the method

url: url,
type: “POST”,
cache: false,
contentType: “application/json; charset=utf-8”,
data: data,
dataType: “json”,
success: function (data) {

error: function (msg) {