with an ajax post to php can i send multiple variables, and if so whats the syntax?
loadXMLDoc("scripts/product_transfer.php?group="+group+"subgroup="+subgroup+"user="+user+,function()
something like that??
here is the function code:
//--------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------
//Function to handle ajax
function loadXMLDoc(url,cfunc)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=cfunc;
xmlhttp.open("POST",url,true);
xmlhttp.send();
}
Yes you can but you have forgotten the &s between values. You can also send data with POST method as argument to send() method. Also don't forget to use encodeURIComponent() on string values:
xmlhttp.open( "POST", url, true );
xmlhttp.send( "group="+encodeURIComponent(group)+
"&subgroup="+encodeURIComponent(subgroup)+
"&user="+encodeURIComponent(user) );
You should add & or '&'; between different variables in query string like
scripts/product_transfer.php?group="+group+"&subgroup="+subgroup+"&user="+user
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With