I
Igal
i just started working with ajax, and werid thing happens.
i have a function that build my post string for ajax to send. it looks
like this:
function buildPOST(formName, formTask) {
theForm = document.getElementById(formName);
var qs = ''
for (e=0;e<theForm.elements.length;e++) {
if (theForm.elements[e].name!='' && theForm.elements[e].type !
= 'button' && theForm.elements[e].type != 'submit') {
var name = theForm.elements[e].name;
qs+=(qs=='')?'':'&'
qs+= name+'='+escape(theForm.elements[e].value);
}
}
if (formTask != null) { qs+="&task="+formTask; }
qs+="\n";
return qs
}
and this how i send it...
var postString = buildPOST(...);
....
xmlHttp.send(postString);
i have noticed that when i us $_POST['task'] with PHP (the last var in
the line) its actually that data + whitespace, so i need to do
trim($_POST['task']), question is why this happens? i don't think it's
the buildPOST func, since i tried tirming befor sending with ajax.
i have a function that build my post string for ajax to send. it looks
like this:
function buildPOST(formName, formTask) {
theForm = document.getElementById(formName);
var qs = ''
for (e=0;e<theForm.elements.length;e++) {
if (theForm.elements[e].name!='' && theForm.elements[e].type !
= 'button' && theForm.elements[e].type != 'submit') {
var name = theForm.elements[e].name;
qs+=(qs=='')?'':'&'
qs+= name+'='+escape(theForm.elements[e].value);
}
}
if (formTask != null) { qs+="&task="+formTask; }
qs+="\n";
return qs
}
and this how i send it...
var postString = buildPOST(...);
....
xmlHttp.send(postString);
i have noticed that when i us $_POST['task'] with PHP (the last var in
the line) its actually that data + whitespace, so i need to do
trim($_POST['task']), question is why this happens? i don't think it's
the buildPOST func, since i tried tirming befor sending with ajax.