문제

여기에 HTTPS 페이지에서 HTTP 페이지에서 콘텐츠에 액세스하려고 시도하고 있습니다. 브라우저 콘솔에서 불안한 콘텐츠라는 오류가 발생합니다. 다음은 오류가 'Loading (불안정) 활성 콘텐츠에 오류가 있습니다.안전한 페이지 " http://pnrbuddy.com./ API / Station_BY_Code / Code / CNB / FORMAT / JSON / PBAPIKEY / 539FF0F815CA697C681FE01D32BA52E3 / PBAPISIGN / 906544CA31F9C0048E80BDE8127556AFDE8127556AF828E313B "" '는 JSON Inbrowser 콘솔을 보여 주지만 읽을 수 없습니다.그 JSON을 어떻게 읽을 수 있습니까?

'use strict';

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

(function () {

    // 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();

        $("#button1").click(function()
        {
                paraupdate();   
        });

    });

    // This function prepares, loads, and then executes a SharePoint query to get 
    // the current users information

    function paraupdate()
    {

        var str=""+$("#textbox1").val();
        alert(""+str);
        var message = str+"json539ff0f815ca697c681fe01d32ba52e3";
        var secret = "<my private key>";
        var crypto = CryptoJS.HmacSHA1(message, secret).toString();
        alert("crypto answer is " + crypto);
        var siteurl="http://pnrbuddy.com/api/station_by_code/code/"+str+"/format/json/pbapikey/539ff0f815ca697c681fe01d32ba52e3/pbapisign/"+crypto;


        //////////////////////////////////////////////
         $.ajax({
            url: siteurl,
            type: "GET",
            dataType: 'json',
    /*  headers: {
                "accept": "application/json;odata=verbose",
            },   */
            success: function (data) {
                alert("Success");
                alert(data.Station);
            /*  $.each(data.d.results, function (index, item) 
                {     

                   alert("My ID"+index);
                    alert("Item"+item);
                });

                //var str=JSON.parse(data);

                 var myResults = [];
            $.each(data, function (index, item) {
                alert("dsfsd"+item.station_by_code)
                myResults.push({
                    id: item.id,  

                    //text: item.first_name + " " + item.last_name
                }); 
            });     */

            },
            error: function (error) {
                alert("IN Error");
                alert(JSON.stringify(error));
            }
        });
        /////////////////////////////////////////////

    }

    function getUserName() 
    {
        context.load(user);
        context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);
    }

    // This function is executed if the above call is successful
    // It replaces the contents of the 'message' element with the user name
    function onGetUserNameSuccess() 
    {
        $("#label1").html("Enter Station Code : ");
        $("#button1").val("CLICK");

    }

    // This function is executed if the above call fails
    function onGetUserNameFail(sender, args) {
        alert('Failed to get user name. Error:' + args.get_message());
    }



})();
.

도움이 되었습니까?

해결책

'사용하십시오. ";

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();

    $("#button1").click(function()
    {
            paraupdate();   
    });

});

// This function prepares, loads, and then executes a SharePoint query to get 
// the current users information

function paraupdate()
{

    var str=""+$("#textbox1").val();
    alert(""+str);
    var message = str+"json539ff0f815ca697c681fe01d32ba52e3";
    var secret = "<my private key>";
    var crypto = CryptoJS.HmacSHA1(message, secret).toString();
    alert("crypto answer is " + crypto);
    var siteurl="http://pnrbuddy.com/api/station_by_code/code/"+str+"/format/json/pbapikey/539ff0f815ca697c681fe01d32ba52e3/pbapisign/"+crypto;


    //////////////////////////////////////////////
     $.ajax({
        url: siteurl,
        type: "GET",
        dataType: 'json',
        success: function (data) {
            alert("Success");
            alert(" Code : "data.stations[0].code+" Name : "+data.stations[0].name);

        },
        error: function (error) {
            alert("IN Error");
            alert(JSON.stringify(error));
        }
    });
    /////////////////////////////////////////////

}

function getUserName() 
{
    context.load(user);
    context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);
}

// This function is executed if the above call is successful
// It replaces the contents of the 'message' element with the user name
function onGetUserNameSuccess() 
{
    $("#label1").html("Enter Station Code : ");
    $("#button1").val("CLICK");

}

// This function is executed if the above call fails
function onGetUserNameFail(sender, args) {
    alert('Failed to get user name. Error:' + args.get_message());
}
.

});

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top