我有一个dictionary of arrays
我希望传递给我的Django视图。
$.ajax({
url: '/fund_monitor/fund_directory',
type: 'GET',
data:{
filter_dict: filter_dict,
},
success: function (data) {
console.log(filter_dict);
}
});
在我看来,我希望收到这个词:
if request.is_ajax():
filter_dict = request.GET.getlist('filter_dict')
print("Is Ajax", filter_dict)
但"Is Ajax []"
打印出来,仅作为示例,我的filter_dict
:
Designated Broker:["BMO"]
Fund Class:["OM"]
为什么要传递空白数组?
答案 0 :(得分:1)
$.ajax({
url: '/fund_monitor/fund_directory',
type: 'GET',
data:JSON.stringify({
filter_dict: filter_dict,
}),
success: function (data) {
console.log(filter_dict);
}
});
if request.is_ajax():
request_data = json.loads(request.GET)
filter_dict = request_data['filter_dict']
print("Is Ajax", filter_dict)