When the convertir()
method is executed, all data in the table is converted to JSON , but I need to get the data for each row instead of the entire table. How can I do that?
Javascript Code:
function convertir() {
var table = $('#tabla_json').tableToJSON({
ignoreColumns: [0]
});
return table;
}
$(document).ready(function(){
//Ajax Post
$('#aceptar').click(function(){
$.ajax({
type: "POST",
url: "/fondo_habitacional/guardar_tabla/",
dataType: "json",
data: {"table": JSON.stringify(convertir())},
success: function(data){
alert(JSON.stringify(data));
}
});
});
});
In the views ( View
):
def guardar_tabla(request):
if request.is_ajax() and request.POST:
data = request.POST.get('table')
return HttpResponse(json.dumps(data), content_type='application/json')
else:
raise Http404
Table:
This is the table which I enter the data, what I need is to save the data that I enter in this table to the database .. For this the function converts me to json and with ajax I owe it to send to the Database ..