开发者

How to avoid IE warning message when consuming a web service using jQuery

开发者 https://www.devze.com 2023-01-10 10:17 出处:网络
someone kindly posted the following solution to consuming web services from this question at this link:

someone kindly posted the following solution to consuming web services from this question at this link:

How to use jQuery to call an ASP.NET web service?

function InfoByDate(sDate, eDate){
var divToBeWorkedOn = '#AjaxPlaceHolder';
var开发者_StackOverflow webMethod = 'http://MyWebService/Web.asmx/GetInfoByDates'
var parameters = "{'sDate':'" + sDate + "','eDate':'" + eDate + "'}"

$.ajax({
        type: "POST",
        url: webMethod,
        data: parameters,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {    
                $(divToBeWorkedOn).html(msg.d);
        },
        error: function(e){
                $(divToBeWorkedOn).html("Unavailable");                          
        }
});

}

It all goes well, and the data that I want is returned, BUT, I always get a warning from IE about 'This page is accessing information which is not under its control. This poses a security risk ... etc', and with Opera the information does not load because of a "Security violation" error.

How do I overcome this - I really need to stick with javascript because the code has to be placed in pages where I do not have access to the server programming facilities.

Thanks people.


You can only access web services from your local domain. You'll have to create a proxy locally that passes on the data returned from that remote web service. That is, if the web service is actually remote. If not, use a relative or absolute path to the ws.

0

精彩评论

暂无评论...
验证码 换一张
取 消