Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-95] Override built-in XMLHttpRequest to use Titanium.Network

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:51:58.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsxhr
ReporterJeff Haynie
AssigneeJeff Haynie
Created2011-04-15T02:23:35.000+0000
Updated2011-04-17T01:51:58.000+0000

Description

To make it seamless to support libraries such as jQuery, Mootools, YUI, etc that have their own AJAX convenience methods, we need to patch XMLHttpRequest to use Titanium.Network.createHttpClient

such as:


window.XMLHttpRequest = function() {
    return new Titanium.Network.createHTTPClient()
};

test case w/ jquery:


$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&;tagmode=any&format=json&jsoncallback=?",
                function(data)
{
         $.each(data.items, function(i,item){
        $("<img/>").attr("src", item.media.m).appendTo("#log");         
            if ( i == 3 ) return false;
        });
});

(make sure you create a div with id log in HTML)

Comments

  1. Jeff Haynie 2011-04-15

    (from [e17973888aeeb96107d4885609ba3f413c1db21d]) [#95 state:resolved] monkey patch XMLHttpRequest to use built-in Titanium.Network http://github.com/appcelerator/titanium_mobile/commit/e17973888aeeb96107d4885609ba3f413c1db21d"> http://github.com/appcelerator/titanium_mobile/commit/e17973888aeeb...

JSON Source