i'm trying send array js, can't have answer want.
this php code:
$output = array('total'=>(float)$bhoras[1]'gastas'=>(float)$bhoras[2]); echo json_encode($output); and js code:
function projectselect() { var proj = document.getelementbyid('projetosselect').value; $.ajax({ url: 'crm files/tsread.php', type: "post", data: ({projetosselect: proj}), complete:function(data) { var horas = data.responsetext; alert(horas); // response -> {"total":146,"gastas":84.5} alert(horas[3]); // response -> o } }); } i want "146" , "84.5".
i tried do, alert(horas['total']), alert(horas.total), give me undefined
just specify datatype: "json" , jquery parse response you:
function projectselect() { var proj = $('#projetosselect').val(); $.ajax({ url: 'crm files/tsread.php', type: "post", data: ({projetosselect: proj}), datatype: "json", success: function(horas) { alert(horas.total); } }); }
Comments
Post a Comment