0

I have a web service, built by third party. I just want to consume it. I am doing this using JQuery as Below.

var dwhServiceUrl = 'http://10.62.210.138/DWHWebService/hubservice.asmx/GetHubDetailUser';
            // call segmentation svc
            CallAjaxAsync('POST', SegmentSuccess, '', dwhServiceUrl,
                          {
                              strWSUserName: 'XXX',
                              strWSPassword: 'XXX',
                              strApplicationId: '1',
                              strCompanyId: '1',
                              strRole: 'XXX',
                              strUserID: 'XXX',
                              strOptionList: 'HIGHLIGHT',
                              strFieldName: 'POLICY NO',
                              strFieldValue: '<%=Session["Source_Policy_No"]%>'
                          });

Where CallAjaxAsync definition is

function CallAjaxAsync(type, FuncSuccess, FuncError, url, param) {
    if (param != '') {
        param = JSON.stringify(param)
    }
    $.ajax({
        type: type,
        url: url,
        data: param,
        async: true,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: FuncSuccess,
        error: FuncError,
        headers: {
            "Authorization": "apikey:APIKEY,tokenid:4a5ba979-0c56-468d-87c7-30a22759f7ce",
            "Accept-Language": "en-US"
        }
    });

But I am not receiving any response. It's status is Cancelled and method in OPTIONS on Network tab of console.

enter image description here

Imad
  • 7,126
  • 12
  • 55
  • 112
  • You may need to ask this third party to have CORS enabled or you may need to make the request through a proxy on the same domain as your JS application. See this related [post](http://stackoverflow.com/questions/1099787/jquery-ajax-post-sending-options-as-request-method-in-firefox). – simonl Sep 16 '15 at 13:02
  • @simonl thank you. I will consider your advise – Imad Sep 16 '15 at 14:36
  • @simonl I can access that service through browser on my machine, still it is CORS problem? – Imad Sep 18 '15 at 05:38
  • Not exactly, what I was referring to was your browser's impl of the cross-origin policy - see (here)[https://en.wikipedia.org/wiki/Same-origin_policy]. You basically aren't allowed to hit an endpoint that lives on a different domain it's a security feature. CORS lets you get around this but has to be enabled on the server. People typically get around this by having a proxy (e.g. Node) server make requests on behalf of your JS app – simonl Sep 18 '15 at 15:33

0 Answers0