heron
heron

Reputation: 3661

Strange $.post behaviour

My function works with dynamic (ajax) content and looks like that. I clearly see on firebug that ajax query gets response from serverside. But $(".playlist-content").html(result); doesn't happen at all. Furthermore, I placed alert to test if function gets there. But neither before nor after $(".playlist-content").html(result); alert not happened.

$(document).on("click", "#pl-edit", function (e) {
    e.preventDefault();
    var plid = $(this).data("plid");
    $.post("/playlist/edit", {
        plID: $(this).data("plid"),
        op: "formRetrieve"
    }, function(result) {
        alert("here"); //for testing
        $(".playlist-content").html(result);
        alert("here"); //for testing
    }, "json");
});

What am I doing wrong? Any suggestions?

Upvotes: 0

Views: 33

Answers (1)

Tural Ali
Tural Ali

Reputation: 23240

The problem is, in your function You're using json as content type and your server returns html/text content. Remove json from your function and you're good to go.

Upvotes: 1

Related Questions