Closed Bug 341610 Opened 14 years ago Closed 14 years ago

XMLHttpRequest: this object in onreadystatechange

Categories

(Core :: XML, enhancement)

1.8 Branch
x86
Linux
enhancement
Not set

Tracking

()

RESOLVED DUPLICATE of bug 198595

People

(Reporter: jordan.osete, Unassigned)

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.3) Gecko/20060326 Firefox/1.5.0.3 (Debian-1.5.dfsg+1.5.0.3-2)
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.3) Gecko/20060326 Firefox/1.5.0.3 (Debian-1.5.dfsg+1.5.0.3-2)

Hello.
Actually it's between bug report and feature request, but it should be very easy to implement anyway.

When using an XMLHttpRequest object to load some data, the "this" object in the onreadystatechange function is not referring to any object (it shows strange stuff when displaying it). I think it would be more logical to let "this" refer to the related request object. That will help in case multiple requests are sent at the same time.

Current browser support:
Konqueror doesn't yet support that, but Opera 9 and IE 6 already do.

Thanks.

Reproducible: Always
Could you provide a testcase please?
Assignee: nobody → xml
Severity: minor → enhancement
Component: General → XML
Product: Firefox → Core
QA Contact: general → ashshbhatt
Version: unspecified → 1.8 Branch
Sorry, I forgot to add a testcase. Here is a simple one:

req=new XMLHttpRequest();
req.open('GET', 'somefile.xml');
req.onreadystatechange=function (){
  if(req.readyState==4){
    alert('The "this" object:\n\n'+this);
    alert(this==arguments.callee);
    alert(this==req);
  }
}
req.send(null);

I also uploaded it here:
  http://ministeyr.free.fr/testcases/ajax.htm
It seems that the "this" object is actually pointing to the "arguments.callee" (ie. the function itself).

*** This bug has been marked as a duplicate of 198595 ***
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.