I have a problem in calling my python function from my javascript file.
I'm using a simple server with python3 -m http.server
, so no actual backend..my javascripts are in the front end.
I have a python file called write.py
it has a function that I want to execute from my javascript file
write.py file:
def save_vit(text,name):
f = open(name + ".xml", "w+")
f.write(text)
f.close()
the javascript part that i have tried:(but didn't work)
$.ajax({
type: "POST",
url: "write.py",
data: { text: xmlDoc,name: name}});
xmlDoc is a string that has an xml document.
name is a variable that has the name of the file for the python function.
So my question is, what am I missing to call write.py
from my js file or how to call it if this approach is wrong?