I'm pretty lost, all I want to do is spend a array to my javascript code. I've seen a lot of examples, but none ends me working. I need some help. I'm pretty stuck.
functions.js
function cargaTemperatura(idsem){
$.ajax({
type: "POST",
url: "load_temp.php",
data: { idsem : idsem },
dataType: "json",
success: function(data){
alert(JSON.parse(data));
},error: function(data){
alert('error');
}
});
};
load_temp.php
<?php
include_once 'Includes/db.php';
$select = "SELECT * FROM CalTmp WHERE idsem='".$_POST['id_sem']."'";
$result = mysqli_query($link, $select) or die($select);
$array = mysqli_fetch_all($result,MYSQLI_ASSOC);
debug_to_console($result->num_rows);
debug_to_console($_POST['id_sem']);
echo json_encode($array);
</div>