Search This Blog

Monday, May 17, 2010

Send html array as post variable using Request.JSON

Programmer Question

I have an html:



First name: 

Last name:

Math

Science

History

etc.....


I want to send(using post method) the selected categories(category[]) via mootools ajax so that if I dump the $_POST variable in the server I will get something like:



array(1) {
[category]=>
array(2) {
[0]=>
string(4) "Math"
[1]=>
string(7) "History"
}
}



What should be the javascript(mootools) code for it? Below is my partial code.



new Request.JSON({url: '/ajax_url',
onSuccess: function(){
alert('success');
}
}).post(???);


Note that I don't want to send first_name and last_name fields. I only want to send the category field which is an html array.



Find the answer here

No comments:

Post a Comment

Related Posts with Thumbnails