我正在尝试根据 4 个下拉列表中的不同选择来传递查询字符串。我通过变量传递查询字符串,但它被转义,因此结果是 404 错误。
这是我为制作查询字符串而编写的代码......
function setQueryString(product,brand,demographic,region)
{
product = dropdownlists.get('Product');
brand = dropdownlists.get('Brand');
demographic = dropdownlists.get('Demographic');
region = dropdownlists.get('Region');
if(product !=='' && brand !=='' && demographic !=='' && region !=='')
{
queryString = 'product='+product+'&'+'brand='+brand+'&'+'demographic='+demographic+'&'+'region='+region ;
return queryString;
}
else{console.log('nevermind!!');}
}
There is a view function updating the DataModel model with selected values every time user makes a selection.Based on these selections we get (colorscale) data from the server.
var DataModel = Backbone.Model.extend({
urlRoot : '/api/web/',
idAttribute: 'value',
defaults : {
Product : '',
Brand : '',
Demographic : '',
Region : ''
}
});
var dropdownlists = new DataModel();
var colorscalelist = new ColorScaleModel({value: setQueryString()});
colorscalelist.fetch({success: function(){
console.log(colorscalelist);
}
});
色阶模型是:
var ColorScaleModel = Backbone.Model.extend({
urlRoot : '/api/web/colorscale',
idAttribute: 'value',
defaults : {
DPRBID: " ",
F: "",
BR1: " ",
BR2: " ",
BR3: " ",
UN: " ",
C: " ",
T: " "
}
});
正在传递的 URL 被转换为 ASCII 字符。有没有办法直接通过,不转义。或者,有没有其他方法可以解决发送数据的问题。这是我的第一个 BackboneJS 项目,任何帮助都会很棒。谢谢你。