Hello,
I have custom js, in which I am making ajax POST request and passing form data with file input i.e. multipart form as an argument. Now, I want to catch this (form values+file) in python method. How can I achieve the same?
Also, this js is attached to my html page which is under www. Python file in which method is defined is also under www. i.e. feedback.html, feedback.py.
Here is the code to understand better.
in custom.js file,
$.ajax({ type: 'post', crossDomain: true, url: '/api/method/app.www.feedback.submitForm', headers:headerParams, data: formData, processData: false, contentType: false, success: function(data){ console.log(data); }, error:function(err){ console.log(err); } });
“submitForm” is python method. Now, how I get the values of form inputs including file input passed from ajax to this method. I have checked that it is going inside the method by returning simply a string.
@frappe.whitelist(allow_guest=True, xss_safe=True)
def submitForm():
return “OK”
OR do I need to follow some other steps?