Ajax request to python is not returning anything
تبليغيرجى شرح بإيجاز لمإذا تشعر أنك ينبغي الإبلاغ عن هذا السؤال.
My goal is to get the result from get_maps() in a separate python script ~/mapsinterpeter. The code below doesn’t console.log() anything, despite me telling him to do, when its done. (I want to use [year.value, mapdict.catvalue] as arguments for the function)
function onSubmit(e) {
e.preventDefault()
if(year.value === “” || cat.value === “”) {
msg.textContent = “Please fill out the fields”
msg.classList.add(“error”);
} else {
msg.textContent = “”
msg.classList.remove(“error”);
const catvalue = cat.value
$.ajax({
type: “POST”,
url: “~/mapsinterpeter.py”,
dataType: “python”,
data: {param: [year.value, mapdict.catvalue]}
}).done(function(o) {
list = o
console.log(list)
});
year.value = “”
cat.value = “”
}
}
//Python code:
def get_maps(g):
# code code to build the list “fl”
return fl.append({“maps”: count, “totalelm”: telem})
أضف إجابة