Im not understanding how data goes (via ajax) from client side to serverside and

BACK again? Hey. SO i bought a book on AJAX and css in hopes of figuring out ajax. ive read thru the ajax chapter a few times...and still cant quite figure out how it works.

I think the part that I am most confused about is the .setRequestHeader() method.

here is the part of of the JS method (I now understand the XMLHttprequest part. this is the part after it)

pageRequest.onreadystatechange=function() {
var object = document.getElementById(objectID);
object.innerHTML = pageRequest.responseText;
}
if (dataToSend) {
var sendData = 'sendData=' + dataToSend;
pageRequest.open('POST',url,true);
pageRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
pageRequest.send(sendData);
}
else {
pageRequest.open('GET',url,true)
pageRequest.send(null)
}

I am just not understanding

is it like...when the data is sent (using pagerequest.send(sendData);) it sends the info to the php page and then it returns it aswell at the same time...? or...?

yeah, i just really need clarification on setRequestHeader... :)

Thanks!
I Think what I am trying to say (about the send/sent part) is:

Is it like the php code is included kind of? (like the php method include()... kind of at all? like the code just calls the php code (in a seperate file) as if it were in the same file??
 
Back
Top