Hey everyone.
I have a ready made project to fix where Ajax POST is used to submit information through form by a click. For some reason the post fails about every fourth time and does not save the information. Post goes through function (code below) and error (no description about error) in Firebug points to the last line of the code. The strange thing is that error occurs every time, but sometimes the post gets through. As being pretty new with Javascript Ajax I don't know how to solve this. Help would be highly appreciated and more information will be provided when required. Thanks in advance!
[CODE=javascript]XHR.prototype._ load = function(url,ob ject) {
var _this = this;
if (window.XMLHttp Request) {
this.http_reque st = new XMLHttpRequest( );
} else if (window.ActiveX Object) { // IE
try {
this.http_reque st = new ActiveXObject(" Msxml2.XMLHTTP" );
} catch (e) {
try {
this.http_reque st = new ActiveXObject(" Microsoft.XMLHT TP");
} catch (e) {}
}
}
this.http_reque st.onreadystate change = function(){_thi s.getRequest()} ;
this.http_reque st.open("POST", url,true);
this.http_reque st.setRequestHe ader("Content-Type","applicat ion/x-www-form-urlencoded");
if (document.getEl ementById('text area_url')){
document.getEle mentById('texta rea_url').value += url + "\n\n" + ((object!=false )?get(document. getElementById( object)):'');
}
this.http_reque st.send('xml=<r oot>' + ((object!=false )?get(document. getElementById( object)):'') + '</root>');
}[/CODE]
I have a ready made project to fix where Ajax POST is used to submit information through form by a click. For some reason the post fails about every fourth time and does not save the information. Post goes through function (code below) and error (no description about error) in Firebug points to the last line of the code. The strange thing is that error occurs every time, but sometimes the post gets through. As being pretty new with Javascript Ajax I don't know how to solve this. Help would be highly appreciated and more information will be provided when required. Thanks in advance!
[CODE=javascript]XHR.prototype._ load = function(url,ob ject) {
var _this = this;
if (window.XMLHttp Request) {
this.http_reque st = new XMLHttpRequest( );
} else if (window.ActiveX Object) { // IE
try {
this.http_reque st = new ActiveXObject(" Msxml2.XMLHTTP" );
} catch (e) {
try {
this.http_reque st = new ActiveXObject(" Microsoft.XMLHT TP");
} catch (e) {}
}
}
this.http_reque st.onreadystate change = function(){_thi s.getRequest()} ;
this.http_reque st.open("POST", url,true);
this.http_reque st.setRequestHe ader("Content-Type","applicat ion/x-www-form-urlencoded");
if (document.getEl ementById('text area_url')){
document.getEle mentById('texta rea_url').value += url + "\n\n" + ((object!=false )?get(document. getElementById( object)):'');
}
this.http_reque st.send('xml=<r oot>' + ((object!=false )?get(document. getElementById( object)):'') + '</root>');
}[/CODE]
Comment