On the server-side, I am just printing out the json-as-dictionary to the console
@app.route('/',methods=['GET','POST'])
@login_required
def index():
if request.method == "POST":
print request.json.keys()
return "hello world"
Now, whenever I make a post request via ajax, the console prints out the dictionary with the contents I need.
On the client-side, I have been trying to use various methods to execute some jquery based on a successfull ajax call. I just realized that this might be an error on my server-side, i.e I am not sending any request header to tell jquery that its ajax call was a success.
So how do I send an OK status back to my client to tell it everything is all right?
For the sake of completeness, here is my clientside code
$.ajax({
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(myData),
dataType: 'json',
url: '/',
success: function () {
console.log("This is never getting printed!!")
}});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…