所以我有這種形式的(一些元件爲了清楚而移除)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