[TIMOB-95] Override built-in XMLHttpRequest to use Titanium.Network
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:51:58.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | xhr |
Reporter | Jeff Haynie |
Assignee | Jeff Haynie |
Created | 2011-04-15T02:23:35.000+0000 |
Updated | 2011-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)
(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...