Skip to content Skip to sidebar Skip to footer

Json_encode Not Working With $.get()

I have a file graph.php, where I am writing both the php code and javascript code.I am using flot to plot graph While passing the response, I am using json_ecode($arr); but I am no

Solution 1:

Try doing something with the AJAX response, or at least inspecting it:

$('#btn'. click(function () {
    $.get("graph.php")
    .done(function (response) {
        console.log(response);
    })
    .fail(function (err) {
        console.log(err);
    });
});

Solution 2:

You can try some simple array for testing. Not MySql result.

<?php$arr = array('action' => 'test', 'data' => 'testing');
header("Content-type: application/json");
echo json_encode($arr);

Post a Comment for "Json_encode Not Working With $.get()"