External Ajax Call in Sharepoint 2013: Access is Denied -
so, trying make extremely simple sharepoint application. want built , hosted web application loaded within sharepoint page header.
the goal load in html alternate page , place in div on sharepoint application's default.aspx. same way we've pulled in external project non-sharepoint web application absolutely no difficulties.
so, have made following ajax call:
$.ajax( { type: "get", url: "http://pageiwanttoload/default.aspx", datatype: "html", success: function (result) { $("#pagecontainer").html(result); }, error: function (jqxhr, textstatus, errorthrown) { alert("oops"); } }); however, access denied error.
i've checked few similar stackoverflow , other online requests, of them seemed dealing more complicated systems/situations.
any appreciated.
consider article: http://msdn.microsoft.com/en-us/library/jj164022.aspx. need use sharepoint cross-domain library, if want make javascript request sharepoint. there example of requesting sharepoint 2013 rest service sharepoint itself. i'm used script on demand library , mquery (sharepoint built-in analog of jquery). , sp.requestexecutor - cross-domain sharepoint library.
sp.sod.executefunc('mquery.js', 'm$', function() { m$.ready(function() { sp.sod.registersod('sp.requestexecutor.js', '/_layouts/15/sp.requestexecutor.js'); sp.sod.executefunc('sp.requestexecutor.js', 'sp.requestexecutor', function() { var targetsiteurl = "http://mysiteurl"; var targeturl = "http://mysiteurl/_api/web/lists/getbytitle('mylisttitle')/items(1)"; var re = new sp.requestexecutor(targetsiteurl); re.executeasync({ url: targeturl, headers: { "accept": "application/json; odata=verbose" }, method: 'get', success:function(response) { var jsonobject = json.parse(response.body); } }); }); })}); the key requestexecutor. if want request sharepoint external resource - need accesstoken. hope helps.
Comments
Post a Comment