I'm trying to implement in place editing in html5. Trying to implement this
http://w3lessons.info/2014/04/13/html5-inline-edit-with-php-mysql-jquery-ajax/
But in flask,ajax and jquery instead. When I send ajax request to flask app, it cannot seems to access data i pass for "dd" tag. This is the route function I have
@app.route('/updateNode', methods=['POST'])
def updateNode():
fieldToEdit = request.args.get('fieldToEdit', None)
value = request.args.get('value', None)
app.logger.debug(value)
app.logger.debug(fieldToEdit)
if value == None:
return jsonify(success=0)
else:
return jsonify(success=1)
Always see None when I check using app.logger.debug(value)
DEBUG in view: None
DEBUG in view: None
My Ajax code is something like this
<script>
$(document).ready(function(){
$("dd[contenteditable=true]").blur(function()
{
var field_user = $(this).attr("id") ;
var value = $(this).html() ;
console.log(field_user);
console.log(value);
$.ajax({
type: "POST",
url: "/updateNode",
data: {
'fieldToEdit' : field_user,
'value': value
},
dataType: "text",
success: function(rsp){
console.log("Ajax call was successful" + rsp);
},
error: function(e) {
console.log('request failed ' + e);
}
});
});
});
</script>
I can see right value in developer tool console before making ajax call.
My Html code
<li>
<dl>
<dt>Age</dt>
<dd id="editAge"contenteditable="true">40</dd>
</dl>
</li>
Sample code in runnable http://code.runnable.com/me/VqbxNjRjLVNkRnxN
.html() should only return value, so I cannot understand why request.args.get cannot retrieve value from key value pair supplied in data