I'm working with a php code where I get variables from an input and using ajax
code:
$.ajax({
type: "GET",
url: "controller/appointment/src_agenda.php",
data: {
function: "professional",
variable: professional,
},
dataType: "html",
fail: function( jqXHR, textStatus, errorThrown ) {
alert(jqXHR);
},
error: function (jqxhr, ajaxOptions, thrownError) {
alert(JSON.stringify(jqxhr));
alert(jqxhr.status);
alert(thrownError);
},
success: function(data){
console.log(data);
}
});
I get an array in the success function:
object(mysqli_result)#3 (5) {
["current_field"]=>
int(0)
["field_count"]=>
int(6)
["lengths"]=>
NULL
["num_rows"]=>
int(76)
["type"]=>
int(0)
}
If I use php foreach it shows all the rows, but I tried javascript data.forEach and it says it doesn't exist. I also tried for(var element of data) but it shows each character as an individual.
How can I show each row from this query result in javascript?
This is the code of the model:
$sql = "SELECT medical_agenda_id, day, `date`, time_start, time_end, hour_status_id FROM medical_agenda WHERE hour_status_id>='0' AND professional_id='".$id."' ;";
var_dump($sql);
$res = $this->db->query($sql);
return $res;
I need to put the result in the success function