I am making a new plugin for myself in which i need to send some extra data through the server header variables. Since the current official ajax plugin does not support this feature i have to create a new by myself.
But the problem i am facing is , when i set the header variables then it stop posting the data and i see no header variables on my server side script at all.
the changes what i done is i have just made a new action which takes server header variables... but for the debugging purpose i have added explicitly some header varibales in think it will reach the server...but strangely it never works through plugin. But if i write ajax code in some test html pages and if i apply same way to the header then it works fine.
I dont understand why it is not working here is the sample of my plugin which is also available on my dropbox shared link
dl.dropboxusercontent.com/u/104183650/ajaxhd.zip
if(method_ === "POST" && data_ && hdata_)
{
if (request["setRequestHeader"])
{
request["setRequestHeader"]("Content-Type", "application/x-www-form-urlencoded");
request["setRequestHeader"]("X-UserMail", "faa@kkk.com");
request["setRequestHeader"]("X-Number", "hdj2723");
request["setRequestHeader"]("X-Token", "80e68a4679e864ec99058b609d29f34523e");
// alert("HDPOST "+request["setRequestHeader"]);
}
request.send(data_);
}
the hdata_ is new header data which fill with some variables but for the sake of testing i have hard coded some header data...the function always gets call and these header settings always works but when i call send then i recieve no POST data nor SERVER variable data...using same stuff with testing page with javascript works fine below is the successful test
<script type="text/javascript">
function fetchStatus(address) {
var client = new XMLHttpRequest();
client.onreadystatechange = function() {
// in case of network errors this might not give reliable results
if(this.readyState == this.DONE)
returnStatus(this.status);
}
client.open("POST", address);
client["setRequestHeader"]("Content-Type", "application/x-www-form-urlencoded");
client["setRequestHeader"]("X-UserMail", "faa@kkk.com");
client["setRequestHeader"]("X-Number", "hdj2723");
client["setRequestHeader"]("X-Token", "80e68a467969058b609d29f34523e");
client.send("mail=abc@akaka.com");
}
fetchStatus("http://localhost/myrestapi");
</script>