Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #5741 (closed defect: wontfix)

Opened 2 years ago

Last modified 2 years ago

Ajax.Request.onException() can be throw repetitiously, Ajax.activeRequestCount is incorrect

Reported by: subchen@gmail.com Assigned to: sam
Priority: high Milestone:
Component: Prototype Version:
Severity: normal Keywords: Ajax,onException,activeRequestCount
Cc:

Description

if Network Error else throw onException repetitiously.

Sample:

var myGlobalHandlers = {
    onException: function(request, exception) {
    	alert("Js Exception: " + exception);
    }
};

Ajax.Responders.register(myGlobalHandlers);

result: (twice is same)

alert("JS Exception: XXXX"); alert("JS Exception: XXXX");

=====================================

Ajax.activeRequestCount is incorrect

if OnErrception then Ajax.activeRequestCount--

fixed Code:

Ajax.activeRequestCount_fixed = 0; // fixed: prototype.js BUG!

var myGlobalHandlers = {
    onCreate: function(request, transport) {
    	Ajax.activeRequestCount_fixed++;
    	request.__start = true;
    	
        Element.show(element);
    },

    onComplete: function(request, transport) {
        if (request.__start) {
	        Ajax.activeRequestCount_fixed--;
	        request.__start = false;
	    
	    	if (Ajax.activeRequestCount_fixed == 0) {
	            Element.hide(element);
        	}
        }
    },

    onException: function(request, exception) {
    	if (request.transport)
    		request.transport.abort();

        // fixed. can throw multi-errors.		
        if (request.__start) {
	        Ajax.activeRequestCount_fixed--;
    		request.__start = false;
    	
	        if (Ajax.activeRequestCount_fixed == 0) {
	            Element.hide(element);
	        }

    		alert("Js Exception: " + exception);
    	}
    }
};

Ajax.Responders.register(myGlobalHandlers);

Change History

10/09/06 09:53:03 changed by mislav

  • status changed from new to closed.
  • resolution set to untested.

First part is incomprehensible. The second part is in some way superseded by #6366

11/04/06 21:02:24 changed by mislav

  • status changed from closed to reopened.
  • resolution deleted.

11/04/06 21:02:31 changed by mislav

  • status changed from reopened to closed.
  • resolution set to wontfix.