I am wondering the best way to send more than one record's value to a
controller and then update a database with it. What i want to do is
push a string like:
var data = "[{"id": 1, "val": something},{"id": 2, "val":
somethingElse}]";
into:
$.ajax({
type: "POST",
url: fetchURL("saveAttrs"),
data: attr_data,
// everything below here is unimportant!!!
success: function(msg){
$("li#stats").show().html(msg);
setTimeout(clearStats, 3000);
}
});
I am unsure of how to access this data from the server side. I tried
an example on stackoverflow which was:
def saveAttrs():
import simplejson as json
j = json.loads(request.body.read())
return "success!"
but this gave me an error saying my string wasn't JSON formatted. How
exaclty do i get this data to the server in bulk format instead of
having to update every record independently in the jQuery for each
loop.
Thanks in advance!