Quantcast
Channel: AjaxControlToolkit Work Item Rss Feed
Viewing all articles
Browse latest Browse all 4356

Created Issue: XmlHttpExecutor.abort() always throws an error [27071]

$
0
0
It is impossible to call XmlHttpExecutor.abort() without getting en error, in its current implementation. Here is the current implementation in http://ajax.microsoft.com/ajax/3.5/MicrosoftAjax.debug.js:

function Sys$Net$XMLHttpExecutor$abort()
{
/// <summary locid="M:J#Sys.Net.XMLHttpExecutor.abort" />
if (arguments.length !== 0) throw Error.parameterCount();
if (!this._started)
{
throw Error.invalidOperation(Sys.Res.cannotAbortBeforeStart);
}
if (this._aborted || this._responseAvailable || this._timedOut)
return;
this._aborted = true;
this._clearTimer();
if (this._xmlHttpRequest && !this._responseAvailable)
{
this._xmlHttpRequest.onreadystatechange = Function.emptyMethod;
this._xmlHttpRequest.abort();
this._xmlHttpRequest = null;
this._webRequest.completed(Sys.EventArgs.Empty);
}
}

Function.emptyFunction = Function.emptyMethod = function Function$emptyMethod()
{
/// <summary locid="M:J#Function.emptyMethod" />
if (arguments.length !== 0) throw Error.parameterCount();
}

Specifically this line:

this._xmlHttpRequest.onreadystatechange = Function.emptyMethod;

Function.emptyMethod expects zero arguments and throws an error if any arguments are passed. But the onreadystatechange event will always pass an event object as an argument to its handler. This will always throw an error (unless you are using an older IE browser)!

The onreadystatechange event should not be bound to Function.emptyMethod, it should be set to null.

This code reproduces the problem:

var request = new Sys.Net.WebRequest();
request.set_url("/someUrl");
request.set_httpVerb("POST");
request.set_body("myKey=myValue");
request.invoke();
request.get_executor().abort();

To see the error, view this link with your JavaScript console open:

http://jsfiddle.net/gilly3/dcgCY/


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>