Ajax.Request.prototype.abort = function() { // prevent and state change callbacks from being issued this.transport.onreadystatechange = Prototype.emptyFunction; // abort the XHR this.transport.abort(); // update the request counter Ajax.activeRequestCount--; }; //get the text for the tooltip from a URL and store in cont. cont can be a div tag like this
function getToolTip(url, cont){ var myAjaxRequest = new Ajax.Request(url, { method: 'get', onSuccess: function(transport) { var content = $(cont); content.update(transport.responseText); } }); } //get the text for the tooltip from a URL, create the content div for store the text for a second call function getAjaxToolTip(url, content, fix){ if($(content)){ return TagToTip(content, BALLOON, true, FIX, [fix, 0, 0], WIDTH, 150, CENTERMOUSE, true, FOLLOWMOUSE, false, FONTFACE, 'Arial, sans-serif', CLICKCLOSE, true); }else { var myAjaxRequest = new Ajax.Request(url, { method: 'get', onCreate: function(transport){ Tip("Loading content...", BALLOON, true, FIX, [fix, 0, 0], WIDTH, 150, CENTERMOUSE, true, FOLLOWMOUSE, false, FONTFACE, 'Arial, sans-serif', CLICKCLOSE, true); //cancel the tooltip if the mouse is out of the element Event.observe($(fix), 'mouseout', function(){myAjaxRequest.abort()}); }, onSuccess: function(transport) { var element = new Element('div', {'id': content}); Element.update(element, transport.responseText); Element.hide(element); if(!$('div_tooltips')){ var div_tooltip_element = new Element('div', { 'id' : 'div_tooltips'}); //Element.hide(div_tooltip_element); document.body.appendChild(div_tooltip_element); } Element.insert($('div_tooltips'), {bottom:element}); return Tip(transport.responseText, BALLOON, true, FIX, [fix, 0, 0], WIDTH, 150, CENTERMOUSE, true, FOLLOWMOUSE, false, FONTFACE, 'Arial, sans-serif', CLICKCLOSE, true); } }); } }