我在客户端选择如下:
<select multiple="multiple" id="reason" class="input-xlarge">
<option value="001">reason1</option>
<option value="002">reason2</option>
<option value="003">reason3</option>
<option value="004">reason4</option>
<option value="005">reason5</option>
</select>
使用以下代码将数据发送到服务器:
var reason = $('#reason').val();
$.ajax({
data: {'reason': reason},
...
});
...
在我做的服务器上:
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
arguments = self.request.arguments()
for argument in arguments:
if self.request.get(argument):
self.response.out.write(argument+': '+self.request.get(argument)+'<br>')
结果即使选择了几个原因,我也看到:
reason[]: 002
如何选择所有值?
更新1。它们在请求中传递为:
reason%5B%5D=001&reason%5B%5D=002&reason%5B%5D=003&reason%5B%5D=004