Opened 14 years ago

Closed 14 years ago

#7083 closed enhancement (wontfix)

Allowing AJAX calls to supercede / abort / cancel previous calls within a given class

Reported by: guest Owned by: anonymous
Priority: high Milestone: 1.2
Component: Core Version: 1.1.1
Keywords: Cc:
Blocked By: Blocking:


Please take a look a this Prototype extension.

Would it be possible to add this feature to Dojo?

Here's an example how I would use it.

dojo.xhrGet ({

Location of the HTML content we want to grab url: '/demo-0.9/xhr/content.html',

onlyLatestOfClass: 'classname',

Called when the page loaded successfully load: function (data) {

dojo.byId('html-content').innerHTML = data;


Called if there was an error (such as a 404 response) error: function (data) {

console.error('Error: ', data);



Change History (1)

comment:1 Changed 14 years ago by James Burke

Resolution: wontfix
Status: newclosed

Since dojo.xhrGet returns a dojo.Deferred object, you can create your own wrapper to do this. This is not a common enough use case to warrant inclusion in at least Dojo Core.

Here is how you could do it in your code (untested code, but should hopefully give the idea):


mymodule.mostRecentXhr = {
  _types: {},

  get: function(/*dojo.xhrGet argument object*/args, /*String*/type){
      //There is one of this type in flight, kill it.
      //Objects in this._types are dojo.Deferred objects
      //with a cancel method.
    return (this._types[type] = dojo.xhrGet(args));

Note: See TracTickets for help on using tickets.