Ajax and Flask: returned undefined

  ajax, flask, javascript, jquery, python

I have this problem in my AJAX and Flask.

The error says "Uncaught TypeError: secondPassword is undefined" but secondPassword is Clearly visible in the Ajax part.

This is the AJAX Part:

       data : {
             password : $('#password').val(),
             secondPassword : $('#rePass').val()
       type : 'POST',
       url : '/checkSecondPassword'
           if(secondPassword.error) {

And this is the Flask Part:

@app.route('/checkSecondPassword', methods=['POST'])
def checkSecondPassword():
    if request.method == 'POST':
        password = request.form['password']
        repass = request.form['secondPassword']

        if password != repass:
            return jsonify({'error':"Passwords doesn't match."})

        return ('', 204)

Source: Python Questions