jQuery.ajax({dataType:…}) supports several known dataTypes (xml, json,jsonp, script,text, or html).
Is there a way to add your own datatype handlers like:
var wcf = function(data){...}
jQuery.ajax({dataType:wcf, ...});
Obviously I’ve already tried this, and it doesn’t work. But is there another way?
There isn’t really a clean way to do this, at least not as far as jQuery 1.4.4 simply because there are tons of
if()checks inside$.ajax()that rely on datatypes, and that’s how they’re currently “supported”. However, jQuery 1.4.5 will have some interesting changes here.If you’re curious, you can browse github for the latest and see how jQuery AJAX behavior is being made much more extensible by dividing the transport code: https://github.com/jquery/jquery/tree/master/src/transports