views:

41

answers:

1

Hi,

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

http://stackoverflow.com/questions/230401/how-to-use-jquery-to-call-an-asp-net-web-service/3407545#3407545

function InfoByDate(sDate, eDate){
var divToBeWorkedOn = '#AjaxPlaceHolder';
var 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.

A: 

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.

ScottE
I appreciate your response ScottE - if you care to expand on what it means to create a proxy then I would be obliged. BB.I'll look it up as well :)
Basil Bear