所以我有这种形式的(一些元件为了清楚而移除)Django的request.REQUEST被截断数据
<form id="{{ section }}-submission-form{{ cell_id }}">
<input type=hidden name="section" value="{{ section }}" />
<input type="hidden" name="school" id="{{ section }}-submit-school{{ cell_id }}" />
{% if section == "posts" %}
<input type=hidden name="url" />
<textarea class="{{ section }}txtinput{{ cell_id }}" name="text-submission"
default="{% if is_advice %}What's your question?{% else %}What's on your mind?{% endif %}"
id="{{ section }}-suggestion-box{{ cell_id }}"
style="margin: 0 0 .5em 0;font-family: Arial, sans-serif;font-size: 14px; width: 410px;"
rows='8'></textarea>
<br />
{% endif %}
{% if section == "photos" %}
<span style='line-height: 40px;'>
<label class="photouploadlabel">URL</label><input type="text" name="image-url" style="width: 335px" /><br>
<label class="photouploadlabel">File</label><input type="file" name="image-file" style="width: 335px"/><br>
<label class="photouploadlabel">Caption</label><input type="text" id="image-caption{{ cell_id }}"
name="image-caption" style="width: 335px" default="optional"/>
</span>
{% endif %}
<div id="{{ section }}-bottomdiv{{ cell_id }}" style="height: 45px; margin-top: .5em; width: 413px;">
<div style="height: 45px">
<label id="{{ section }}-tagsbutton{{ cell_id }}"
style="margin-right: .5em; cursor: pointer; vertical-align: bottom; float:left; line-height: 1.8em;">Tags</label>
<input id="{{ section }}-tagsinput{{ cell_id }}" type="text" name="tags-list" style="position: relative"/>
<button id="send-{{ section }}-suggestion{{ cell_id }}" disabled="disabled"
style="float:right; position: relative; bottom: 7px; right: -4px;">Post</button>
</div>
的标签列表输入变成自动完成和用户选择的标签,然后将其加入到全球js变量“选定标签”。当用户按下“邮报”,我有这样的代码:
alert(selectedtags);
$("#"+section+"-submission-form"+cellid).ajaxSubmit({
url: '/save-suggestion/',
type: 'post',
data: {'tags': selectedtags },
dataType: 'json',
success: function(response){
clear_text(section, cellid);
location.reload();
},
这里的怪异位:哪个部分我在,警报作品。但是,如果我打印request.REQUEST在服务器端,如果该节的照片我得到
{u'image-url': u'http://i.imgur.com/vUxla.jpg', u'tags-list': u'', u'tags': u'wtf,crazy,pics', u'section': u'photos', u'school': u'1997', u'anonymity-level': u'schoolandmajor', u'image-file': u'', u'image-caption': u''}
即我想要的东西。但是,如果该节的帖子,我得到
{u'text-submission': u'wtf', u'school': u'1997', u'tags-list': u'', u'url': u'', u'section': u'posts', u'tags[]': u'crazy', u'anonymity-level': u'schoolandmajor'}
因此,不仅是它改名为标签[](这我以前见过和我没有太在意,但是......),它也是我的截断标签列表只是最后一个条目。
有没有人知道我可能会做错什么?
编辑:经过进一步检查,这是使用request.REQUEST正在做的事情,而不是request.POST。
那么,究竟是怎么回事?
+1在django代码(甚至没有显示)中实际显示问题 – Toote 2012-08-09 01:26:32
hm ...我以为我已经尝试了精确的代码片段...也许不是。我会再尝试。谢谢! – Colleen 2012-08-10 02:31:35
是的,我使用的是精确的代码片段,有时它不工作...显示为标签而不是标签[] .... – Colleen 2012-08-13 20:59:01