Error “No Transport” Calling WCF REST action using jQuery

This issue has eaten up some of my time, trying myself to figure it out for the solution. Because, the following snippet worked great in FireFox. Only the boss “IE” was the killer there :).

var url = ‘http://localhost:35461/SampleApp.svc/get/Do/123;’;

        $.ajax({
            url: url,
            dataType: 'json',
            type: "GET",
            error: function (xhr, ajaxOptions, thrownError) {
                //debugger;
                $('#GetDiv').html("error");
            },
            success: function (model) {
                //debugger;
                $("#GetDiv").html(model.Echo);
            }
        });

Finally, after a bit of googling, I have got some references, that helped great.

Gotchas:

“…..We need to enable cross-domain requests in environments that do not support….”

Cors is equal to true if a browser can create an XMLHttpRequest object and if thatXMLHttpRequest object has a withCredentials property. To enable cross-domain requests in environments that do not support cors yet but do allow cross-domain XHRrequests (windows gadget, etc), set $.support.cors = true;”

Hence, the solution is……..

Add the following, in your client. It works like a charm.
jQuery.support.cors = true;

[Cors – Cross-Origin Resource Sharing]

There were some references to use dataType: ‘jsonp’, but that is a different story. I will write some later, what needs to be done if we say dataType: ‘jsonp’

Hope this helps someone…!

Advertisements

5 Comments »

  1. 1
    babu Says:

    helped me a lot for IE using $.support.cors=true

  2. 3

    My pal suggested I might this way weblog. Your dog seemed to be right.

    That truly made my personal evening. You cannot consider the length of
    time I had invested in search of this specific.

  3. 4
    Jayprakash Shevade Says:

    It Worked. Thanks for the help


RSS Feed for this entry

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: