JSONP.js 646 Bytes
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/**
 * JSONP.js
 *
 * Copyright 2009, Moxiecode Systems AB
 * Released under LGPL License.
 *
 * License: http://tinymce.moxiecode.com/license
 * Contributing: http://tinymce.moxiecode.com/contributing
 */

tinymce.create('static tinymce.util.JSONP', {
	callbacks : {},
	count : 0,

	send : function(o) {
		var t = this, dom = tinymce.DOM, count = o.count !== undefined ? o.count : t.count, id = 'tinymce_jsonp_' + count;

		t.callbacks[count] = function(json) {
			dom.remove(id);
			delete t.callbacks[count];

			o.callback(json);
		};

		dom.add(dom.doc.body, 'script', {id : id , src : o.url, type : 'text/javascript'});
		t.count++;
	}
});