[Answered ]-JSON + jQuery $.post + Django –> parsererror – SyntaxError: invalid label

2πŸ‘

βœ…

you need to add β€œjson” after the callback to let jquery know that the return data should be json. jQuery will then automatically parse your json string into a JavaScript object.

$(".edit_rec").click(function () {
    var rec_id = $(this).attr('name');
    $.post("/edit/", {
        editid: rec_id
    }, function (content) {
        var to = new String(content.to_date);
        var from = new String(content.from_date);
    },"json");
});
πŸ‘€Kevin B

Leave a comment