Closed
Bug 371906
Opened 19 years ago
Closed 9 years ago
XMLHttpRequest fires "The open() method has been successfully called." event two times.
Categories
(Core :: XML, defect)
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: sergeyg83, Unassigned)
Details
User-Agent: Opera/9.10 (Windows NT 5.1; U; en)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2
I have a simple class that make an http request to server via XMLHttpRequest. I call XMLHttpRequest::send() in callback function when readyState riches value of 1. In Opera and IE everything seems be ok. But when I try this in FireFox it calls send() method two times. It seems that send() method set readyState to 1 and cals callback function once more time before sending the request.
Reproducible: Always
Steps to Reproduce:
1. Call XMLHttpRequest::send() in XMLHttpRequest::onreadystatechange() callback function on readyState riches value of 1.
Actual Results:
XMLHttpRequest::onreadystatechange() function is called two times whith XMLHttpRequest::readyState setted to 1.
Expected Results:
XMLHttpRequest::onreadystatechange() function should be called only one time whith XMLHttpRequest::readyState setted to 1, after the XMLHttpRequest::open() method was called, but not after XMLHttpRequest::send()
Code example:
this.call=function(method,id)
{
//creating XMLHttpRequest object
..............
//
var httpRequestLocal=this.httpRequests[id];
this.httpRequests[id].onreadystatechange=function()
{
switch (httpRequestLocal.readyState)
{
case 1:
httpRequestLocal.send(JSON_call_object.toJSONString());
break;
case 4:
//parsing response
}
};
this.httpRequests[id].open('POST',url,true);
}
Updated•19 years ago
|
Assignee: nobody → xml
Component: General → XML
Product: Firefox → Core
QA Contact: general → ashshbhatt
Version: unspecified → 1.8 Branch
Comment 1•18 years ago
|
||
I face somewhat similar problem but not sure whether this is exactly similar.
Have a simple class called ajax (tried to do something similar to what prototype.js ajax look like)
ajax = {
_this : null,
_instance : null,
_method : 'GET',
_options : null,
_parameters : "",
parseParameters : function() {
// Parse Parameters
},
getResponseText : function() {
return _this._instance.responseText;
},
getResponseXML : function() {
return _this._instance.responseXML.documentElement;
},
getInstance : function() {
// Returns new xmlHttRequest object
},
// The request execution
request : function(url,options) {
_this = this;
req = _this.getInstance();
_this._options = options;
var params = null;
if (options.method != null && options.method != 'undefined') {
_this._method = options.method;
}
if (options.parameters != null && options.parameters != 'undefined') {
_this._options.parameters = options.parameters;
}
if (_this._method == 'POST') {
params = _this.parseParameters();
} else {
if (_this.parseParameters() != null) {
url = url + '?' + _this.parseParameters();
}
}
if (req != null) {
req.open(_this._method, url, true);
req.onreadystatechange = function() { _this.readyStateChange() ; };
req.send(params);
}
},
// The ready State callback
readyStateChange : function() {
if( _this._instance.readyState == 4 && _this._options.onSuccess != null) {
if( _this._instance.status == 200 && _this._instance.statusText == "OK" ) {
_this._options.onSuccess(_this);
} else {
_this._options.onError(_this);
}
}
}
};
------------------------------------------------------
When I make a call to ajax as below. Only the second request : request_2.jsp gets completed.
Placing alert message in the readyStateChange method, I could get alert for first request (request_1.jsp), followed by second request (request_2.jsp) and immediately again for the second request (request_2.jsp)
So the last request (request_2.jsp) gets further executed and the previous request were ignored.
Here request_2.jsp is sent twice. In IE, it happens for the first time, but subsequent refresh doesn't give the problem.
Firefox - by Rule of Repair always gives this error consistently
ajax.request("request_1.jsp",
{
method : 'GET',
parameters : {param1:'yes'},
onSuccess : handleResponse_request1
}
);
ajax.request("request_2.jsp",
{
method : 'GET',
parameters : {param1:'no'},
onSuccess : handleResponse_request2
}
);
Updated•16 years ago
|
Assignee: xml → nobody
QA Contact: ashshbhatt → xml
Comment 2•9 years ago
|
||
This got fixed.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•