It appears that I am only receiving jQuery results, but I am in search of the correct method to pass parameters via AJAX without using libraries or old browser fallbacks. If there is another thread discussing this topic that I have overlooked, please provide a link =)
The code snippet I am using includes $, however, it is not jQuery, but rather a custom object/implementation.
$.ajax({
't':'POST',
'u':e,
'd':{ajax:'1'},
's':function(data){
console.log(data.response);
document.getElementById('mainc').innerHTML = data.response;
},
'e':function(data){
console.log(data);
}
});
This triggers:
$.ajax = function(a){
if(!a.u){return false;};
a.t=a.t||"GET";
typeof a.a=='undefined'?true:a.a;
a.e=a.e||function(){return false;};
a.s=a.s||function(){return true;};
var x=new XMLHttpRequest();
x.open(a.t,a.u,a.a);
x.onreadystatechange=function(){
if(x.readyState===4){
if(x.status===200){
a.s(x);
}else{
a.e(x);
}
}
};
a.t==="post" ? x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") : null;
x.send(a.d);
}
x.send(a.d)
should transmit the {ajax:'1'}
parameter. I have tested {'ajax':'1'}
and just 'ajax=1'
as well. It seems that none of the parameter variations successfully make it to the server side. Despite the request being sent and received without problems, the parameters do not appear to reach the server.