So I have the function I want to call get_maps() from a separate python file called "mapsinterpeter.py", and I have successfully requested the code, but I still cannot call 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",
data: {async: false},
success: function (response) {
console.log(get_maps(/*args, ect */));
},
});
year.value = ""
cat.value = ""
}
}
Console:
get_maps is not defined
at Object.success (https://6534e288-58df-4278-82e3-7bfc760af484.id.repl.co/script.js:34:20)
at c (https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js:2:28327)
at Object.fireWith [as resolveWith] (https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js:2:29072)
at l (https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js:2:79901)
at XMLHttpRequest.<anonymous> (https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js:2:82355)
source https://stackoverflow.com/questions/72924260/how-to-call-the-python-function-from-the-javascript-ajax-request-result
Comments
Post a Comment