On jQuery.post, I get the message: The method GET is not allowed for the requested URL On jQuery.post, I get the message: The method GET is not allowed for the requested URL flask flask

On jQuery.post, I get the message: The method GET is not allowed for the requested URL


It's because you are passing an object as data like

var message = {    'GRAPH_TYPE': graphType};

In this case jQuery attempts to URL encode the object and by default sends with the data type application/x-www-form-urlencoded; charset=UTF-8 ans sends a GET request. To overcome this problem make sure that you’re passing jQuery a string for the data parameter and to do this you can use JSON.stringify like

var message = JSON.stringify({ "GRAPH_TYPE": graphType });