URL斜杠编码未被执行

时间:2015-02-19 14:07:02

标签: javascript jquery django url urlencode

我有一些django / javascript / jQuery代码,如下所示:

{% url 'motor.core.reports.views.view' 'CDSEM' 'Gallery' as report_url %}
var $item = $(this);
var $row = $item.closest('tr');
var $cols = $row.children('td');
var tool_name = $.trim($cols.eq(2).text());
var tool_id = $('#tools option:contains('+tool_name+')').val();
var date_time = encodeURIComponent($.trim($cols.eq(3).text()) + ' to ' + $.trim($cols.eq(4).text()));
var href = "{{ report_url }}?recipe={{ filters.0.value }}&lot={{ filters.1.value }}&date_time=" + date_time + '&tool_ids=' + tool_id + '&meas_checkbox=Meas&pr_checkbox=PR&ga_checkbox=GA&submit_preview=Generate+Report';
window.open(href, '_blank');

正确编码了date_time字段:

> date_time
< "02%2F05%2F2012%2012%3A12%3A21%20am%20to%2002%2F05%2F2012%2012%3A23%3A04%20am"

但是当浏览器获取URL时,它似乎已被部分解码(斜杠已从%2F转换回斜杠):

http://127.0.0.1/report/CDSEM/Gallery/?recipe=&lot=&date_time=02/05/2012%2012:12:21%20am%20to%2002/05/2012%2012:23:04%20am&tool_ids=22&meas_checkbox=Meas&pr_checkbox=PR&ga_checkbox=GA&submit_preview=Generate+Report

我的应用程序未正确处理date_time参数。

如何将斜杠编码一直保留到我的应用程序中?

0 个答案:

没有答案