Beware when posting data from a multiple select through ajax. You can’t send an array with a Prototype ajax call.


function postmydata(){
new Ajax.Request(‘data.php’,
parameters: {selectdata: $F(‘myselect’)},
onSuccess: function(transport){
var response = transport.responseText || alert(“couldn’t add data”);
onFailure: function(){ $(‘mydiv’).update(‘error’); }

This won’t work. Your php page will not get an array.


replace the parameter part with:
parameters: {selectdata: $F(‘myselect’).join(“,”)}, // this will send a comma seperated string
In your php code use:
$myselect = = explode(‘,’,$_POST[‘selectdata’]);

Related Blogs

Leave a Reply

Your email address will not be published. Required fields are marked *