0
當我用JS代碼分割一些值時,它使用','分隔符將分隔數據發送到視圖 我可以更改分隔符','發送到視圖嗎? 我知道,拆分功能只接受兩個參數.split(分隔符,限制) 這裏的js代碼:將js中的分隔值傳遞給Django視圖
$(document).ready(function() {
$('#searchSubmit').click(function() {
q = $('#q').val().split('\n');
t = $('#t').val();
$('#results').html(' ').load('/?mdhash=' + q + '&type=' + t);
});
});
$(document).ajaxStart(function() {
$('#spinner').show();
}).ajaxStop(function() {
$('#spinner').hide();
});
而這裏的視圖的一部分:
def crackit(self, request):
self.mdhash = request.GET.get('mdhash', '').split(',')[:15]
self.type = request.GET.get('type', '')
self.api = request.GET.get('api', '')
self.clear = {}
self.temp = {}
self.new = {}
self.encrypted = {}
Remote_ip = request.META.get('REMOTE_ADDR').split(':')[-1]
current_path = request.get_full_path()
q是一個mdhash或...?也請閱讀http://www.python.org/dev/peps/pep-0008/ – Willian 2012-04-11 21:19:37
yup q is mdhash – 2012-04-11 21:47:07