خرید بک لینک

Vote count: 0

I am working on a project of a small web-app using JQuery and Flask. I have some trouble in sending data from JQuery to Flask.
A snippet of code on the server side:

@app.route('/_receive_data', methods=['GET', 'POST'])
def _receive_data():
    if request.method == 'POST':
            result = request.json['datas'];
            print(result)
            rows = []
            for r in json.loads(result):
                d = json.load(r)

A snippet of code on the client side:

function new_row(row_id,row_name,row_desc) {
            this.row_id = 0;
            this.row_name = "None";
            this.row_desc = "None";
    } 

    var row_arr = [];
    var row_id = 1;

    $(document).ready(function(){
        $('#confirm').click(function(){
               $("#submit_message").show().delay(1000).fadeOut();
               //TBD: Communicate these data with python via Ajax
               var row_arr_str = JSON.stringify(row_arr)
               $.post('http://127.0.0.1:5000/_receive_data', {datas:row_arr_str});

        }); 
});

When the event happens, the error printed in the terminal is:

line 71, in _receive_data
    result = request.json['datas'];
TypeError: 'NoneType' object is not subscriptable

There is also a 500 inteal server error shown on the webpage

Could anyone tell me what's wrong with my encoding on the client side and/or decoding on the server side?

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 5 خرداد 1395 ساعت: 3:42

صفحه بندی