[eluser]jvk22[/eluser]
I am running a jquery ajax function to get JSON data, the data is returned properly, but when I go to display it, the variable shows up undefined.
Code:
public function ajax_add_new_task()
{
$b ='';
$b .= '<table>';
$b .= '<tr><td>Task Title:</td><td><input type="text" name="title" id="title"></td></tr>';
$b .= '</table>';
$result['success'] = TRUE;
$result['message'] = $b;
echo json_encode( $result);
}
}
Code:
function show_add_task()
{
$.ajax({
type: "POST",
url: "tasks/ajax_add_new_task",
data: {
'submit':'submit',
},
datatype:'json',
success: function(msg) {
alert(msg.message);
$(".add_task").html(msg.message);
}
});
}