1.前端
<script>
var datasss ;
function gof(){
$.ajax({
url: 'data',
type: "POST",
dataType: "json",
data: {
city: document.getElementById("predict_City").value,
type: document.getElementById("predict_Type").value,
day: document.getElementById("predict_Day").value
},
success: function (data) {
datasss = data;
// alert(datasss);
console.log(data)
},
error: function(data) {
alert('获取数据失败')
}
});
}
</script>
2.后台
def main(*args):
test = r"D:\pm\myapp\1.xlsx"
df0 = pd.read_excel(test, index_col=0, parse_dates=[0])
list_city=['南京','无锡','常州','苏州','徐州','南通','连云港','淮安','盐城','扬州','镇江','泰州','宿迁']
list_fc=['粮食加工品','肉制品','乳制品','水产制品']
city = list_city[int(args[0].POST['city'])]
_type = list_fc[int(args[0].POST['type'])]
day = int(args[0].POST['day'])
3.报错
django.utils.datastructures.MultiValueDictKeyError: 'city'