簡體   English   中英

如何在SharePoint托管的應用程序(SharePoint Online)中使用$ .ajax調用外部Restful

[英]How to call an external restful using $.ajax from within a SharePoint-hosted app (SharePoint Online)

如標題所述,我在從SharePoint內部調用外部Restful服務時遇到了麻煩。

'use strict';

var context = SP.ClientContext.get_current();
var user = context.get_web().get_currentUser();

// This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
$(document).ready(function () {
    getUserName();

    $.ajax({
        dataType: "jsonp",
        url: ' http://ip.jsontest.com/',
        success: function (a, b, c) {
            alert(a);
        },
        error: function (a, b, c) {
        }
    });
});
...

這將返回訪問被拒絕。 我一直在兜圈子,試圖弄清楚如何從瀏覽器發出外部呼叫。

如果有更好的方法使用客戶端對象模型來執行此調用,則不需要從jQuery內部進行調用,那么我願意接受任何建議。

這是因為您要從https(在線共享點)調用http Web服務。 將您的網絡服務轉換為https。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM