Create a js variable using a python function [duplicate]

تبليغ
سؤال

يرجى شرح بإيجاز لمإذا تشعر أنك ينبغي الإبلاغ عن هذا السؤال.

تبليغ
‎إلغاء

I created a Python function named get_maps() that has 2 arguments, year and category and I would like to access it from JS, customizing those 2 arguments. However the code below returns an error:

list is not specified

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”);

$.ajax({
type: “POST”,
url: “~/mapsinterpeter.py”,
}).done(function(o) {
list = get_maps(year.value, mapdict.cat.value)
});

year.value = “”
cat.value = “”

console.log(list)
}
}

‫أضف إجابة

تصفح
تصفح

مجهول يجيب