Archive for the ‘jQuery’ Category

Error “No Transport” Calling WCF REST action using jQuery

January 8, 2012

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…!

jQuery 1.5 major changes!

February 23, 2011

jQuery team has released their new version with some significant changes. They are all awesome. Here are some quick notes.

1).  Ajax rewrite
“…Perhaps the largest change is that a call to jQuery.ajax (or jQuery.get, jQuery.post, etc.) now returns a jXHR object that provides consistency to the XMLHttpRequest object across platforms (and allows you to perform previously-impossible tasks like aborting JSONP requests)…”

2). Deferred Objects
It’s an wonderful one!
“….This API allows you to work with return values that may not be immediately present (such as the return result from an asynchronous Ajax request). Additionally it gives you the ability to attach multiple event handlers (something that wasn’t previously possible in the Ajax API)….”

3).  jQuery.sub()
“..you could use it to override native jQuery methods without actually affecting the methods that other users would interact with – or even create encapsulated APIs for your plugins that avoid namespace collision…”

5).  Adjacent traversal performance
“…we’ve also been able to improve the performance of some commonly-used traversal methods: .children(), .prev(), and .next()…”

5).  Build system
Using NodeJS, and avoiding the dependency upon Java/Rhino systems
You can get more information about the jQuery 1.5 on their website