Hi ,
i am using one of the existing code to post ajax request . but i want to set header also for this request . can any one please help to know , how to set the header ?
Below is my code :
dhtmlxAjax.post(storage_server_script, data, function (loader) {
dba.wins.window(“ExportPopup”).setText(“Press link to download file.”);
dba.wins.window(“ExportPopup”).progressOff();
var exportResult = loader.xmlDoc.responseXML.getElementsByTagName(‘ExportResult’).item(0);
if (exportResult != null)
{
dba.wins.window(“ExportPopup”).attachHTMLString("
}
else
{
dba.wins.window(“ExportPopup”).attachHTMLString("
}
});
I am using dhtmlajax.js , and when modified this file for below code
dtmlXMLLoaderObject.prototype.loadXML = function(a, b, c, d) {
this.rSeed && (a += (a.indexOf("?") != -1 ? “&” : “?”) + “a_dhx_rSeed=” + (new Date).valueOf());
this.filePath = a;
this.xmlDoc = !_isIE && window.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject(“Microsoft.XMLHTTP”);
if (this.async) this.xmlDoc.onreadystatechange = new this.waitLoadFunction(this);
this.xmlDoc.open(b ? “POST” : “GET”, a, this.async);
d ? (this.xmlDoc.setRequestHeader(“User-Agent”, “dhtmlxRPC v0.1 (” + navigator.userAgent + “)”), this.xmlDoc.setRequestHeader(“Content-type”,
“text/xml”)) : b && this.xmlDoc.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);
this.xmlDoc.setRequestHeader(“X-Requested-With”, “XMLHttpRequest”);
this.xmlDoc.send©;
this.async || (new this.waitLoadFunction(this))()
};
which is setting request header to set my custom header , it is working , but can we do it out side this dhtmlajax.js ?
by adding some code for
this.xmlDoc.setRequestHeader(“Myheader”, “MyHeader_Value”);