0

I'm sending request through ajax, sending response through Flask.

This is my code

ajax

'''

$.ajax({
    url:'/get',
    type: "post",
    data: {"hi":"hello"},
    success(function(data, textStatus, jqXHR){
        console.log(jqXHR.getResponseHeader('token'));
    })
})

'''

Flask '''

@app.route('/get', methods=['POST'])
def hello():
    data = {'result': 0}
    resp = make_response(data)
    resp.headers['hi'] = 123
    return resp'''

If I run this, I can see response header ('hi', 123) in chrome inspection. But NO CONSOLE LOG.

Is there anything wrong with my code?

1

1 Answer 1

0

There's no token response header in your server response, try reading hi header:

$.ajax({
    url:'/get',
    type: "post",
    data: {"hi":"hello"},
    success(function(data, textStatus, jqXHR){
        // this line: 
        console.log(jqXHR.getResponseHeader('hi'));
    })
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.