Hi,
I have some that submits an array of strings via ajax to be saved on the
server.
Basically, I need to get this same array of strings to be saved in the
order it was passed.
*Below is a snippet from the JS code:
*
function saveArray() {
new_order = ["a", "b", "c", "d"];
var fdata={};
fdata.new_order = new_order;
$.ajax({
url: '/mycontroller/save',
type:"POST",
dataType: 'json',
data:fdata
});
return false;
}
*Controller:*
class OrderForm(formencode.Schema):
new_order = formencode.ForEach(String)
## other fields
@validate(schema=OrderForm(), form='ajax_error', variable_decode=True)
def save(self):
log.debug("All params: %s"%request.params)
new_order=self.form_result.get('new_order')
log.debug("New_order %s"%new_order)
# do something with new_order..
When the request is submitted, the request params received by controller
are:
request.params:
UnicodeMultiDict([('new_order[]', u'a'), ('new_order[]', u'b'),
('new_order[]', u'c'), ('new_order[]', u'd')])
and
self.form_result['new_order'] is an empty array
What I ideally want to have a single array new_order with all the values
in this array.
Any suggestions here?
Thanks,
DD.
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.