kapil k
kapil k

Reputation: 11

Jquery Ajax call to WCF ajax enabled web service not working on Firefox

I have created a WCF ajax enabled web service named "Service1.svc" "I have to call this Service In another app's using Jquery." I have created on method in it :

    [OperationContract]             
    public string GetMarkup()
    {   
       string data = "<div>My HTML markup text here</div>";
       return data;
    }

Now I have created jquery script in my second application's html page :

var markup = "";
$.ajax({
    type: "POST",
    url: "http://localhost:1676/MyWCFService.svc/GetMarkup",
    contentType: "application/json",
    data: "{}",
    dataType: "json",
    success: callback,        
    error: function (textStatus) {
        alert("ERROR");
    }
});
function callback(result) {
    alert("Inside Callback");
    markup = result.d;
    $("#divMyMarkup").html(markup);
    alert(markup);
}

NOW, My Problem is that Whenever I execute this page in IE its working fine. But In Firefox its not working. It giving alert Error Message which defined in error: function (textStatus) {alert("ERROR");} in above ajax call.

I tried this functionality using $.get(), $("#divMyMarkup").load(serviceUrl, callback). I also tried this by changing the datatype as json, jsonp, html . Still I am not getting the exact solution.

Any Expert here?

Upvotes: 1

Views: 2993

Answers (1)

maxbeaudoin
maxbeaudoin

Reputation: 6966

In another app's using Jquery

In my experience, IE won't respect the cross-domain policy and let you do the call, not a reference...

The only way to find out is to have your html page/JQuery script calling your WCF service from http://localhost:1676/ICallWcfServicesWithJQuery.html on Firefox.

Possible solutions:

Test on multiple browsers, add 1oz of gin, a can of tonic and you'll be good!

Upvotes: 3

Related Questions