JS Python interaction with ajax and flask having status 0

I have a JS click function and want to send some data to a python file to process.

In the JS File:

  // did some data collection
    type: "POST",
    url: "/dummy",
    data: {num: 123},
    success: function(result){
    error: function(xhr, status, error){

And in the python file after importing:

app = Flask(__name__)
@app.route('/dummy', methods=['GET', 'POST'])
def dummy(){
  return 1
if __name__ == '__main__':

I keep getting the alert 0 when clicking the button.

Why the ajax request does not pass through and has a 0 status?

Read more here: https://stackoverflow.com/questions/68489891/js-python-interaction-with-ajax-and-flask-having-status-0

Content Attribution

This content was originally published by Tsang Tsz Hin at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: