Rikin Thakkar
Rikin Thakkar

Reputation: 1278

web service call from IE is working but its not working in chrome and mozilla

i am calling web-service using this code:

function CallService() {

    $.ajax({
        type: "GET",
        url: "http://devpc4:5566/Service1.asmx/GetItems",
dataType: "json",
data: "{}",
        contentType: "application/json; charset=utf-8",
        success: OnSuccess,
        error: OnError
    });
}

OnSuccess function:

function OnSuccess(data, status) {
alert("success");

    alert(data.d);
        alert("success1");
    var ponse = '{"TableNo":"2"}';

    alert(ponse.TableNo);

}

OnError:

function OnError(request, status, error) {


    alert(status);
}

it gives me output in IE but i am not getting output in chrome and mozolla.
thanx for your help.

Upvotes: 2

Views: 3761

Answers (2)

Piyush Desai
Piyush Desai

Reputation: 32

By adding these three headers you can get your output

  • Access-Control-Allow-Origin

  • Access-Control-Allow-Methods

  • Access-Control-Allow-Headers

Upvotes: 2

Rikin Thakkar
Rikin Thakkar

Reputation: 1278

got the solution using this link its working.
But i have to add some more headers like:

Access-Control-Allow-Origin
Access-Control-Max-Age
Access-Control-Allow-Methods
Access-Control-Allow-Headers

now its working in mozilla and chrome. thanx guys.

Upvotes: 1

Related Questions