Grow your CSS skills. Land your dream job.

Getting utf-8 problems with .get in jquery code

  • # January 1, 2010 at 9:42 pm

    Hello everyone. Im getting utf-8 problems.
    I have a blog with comments, and if someone writes a new comment while you are reading the comments, it shows a message "Click here to show new comments".

    Im using the next code to call a php page with some data, that returns some HTML with the new comments that I want to show. The problem is that it doesnt show áéó characters. I think it’s because it’s not utf-8, but the comments are perfectly coded in database (utf-8), and they are showed right if I refresh the page. The problem is just the AJAX response.

    Quote:
    $("#notifier").click(function() {
    var post = <?=$post_id?>;
    var last = <?=$currentTime?>;
    $.ajax({
    type: "GET",
    url: "check.php",
    data: ({last : last , post: post , get: 1}),
    dataType: "html",
    contentType: "application/text; charset=utf-8",
    success: function(msg) {
    // Replace the div’s content with the page method’s return.
    $("#newComments").css("display","block");
    $("#newComments").html(msg);
    }
    });
    });

    Any ideas ? What’s wrong? I also tried using the next code, but same behaviour

    Quote:
    $.get("check.php", { last: last , post: post , get: 1} , function(data){
    $("#newComments").css("display","block");
    $("#newComments").html(data);
    });

    Thank you for your help

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".