0

Im using the jquery-forms-plugin and its working great! But now i want to append an array in the beforeSubmit function.

questions = ['hi?','yo?','lol??'];
formData.push({name:'questions',value:questions});

But when i recieve this at my webserver (Using flask.py) it comes just as a plain string. like this: hi?,yo?,lol??

Any input why it does not come as an array or list?

Thanks!

4

1 回答 1

0

formData.push({name:'questions',value:questions});你所拥有的任何东西中questions都会遇到字符串,所以你找到了那个纯字符串。

因此,您可以使用如下所示的字符串,questions并且可以在 python 中显式解析该纯 CSV 字符串。

questions = "'hi?','yo?','lol??'";

您可以再次应用以下技巧:

formData.push({name:'questions[0]',value:'hi?'});
formData.push({name:'questions[1]',value:'yo?'});
formData.push({name:'questions[2]',value:'lol??'});

所以你假设questions在服务器端有列表。

于 2012-04-17T20:00:26.167 回答