I am new with AJAX/jQuery and trying something new.
here is my fiddle for better understanding Each of those squares are DIVS.
<div class="desk_box_ver" id="desk_B20" data-rel="85" style="left:20px;top:1165px;">B20</div>
The number inside of is being retrieved with an AJAX call that GETs it with a PHP script executing a query, it will replace the "B20" for "1300" as an example.
Problem:
How can I produce a "heat map" based on the numbers being displayed. Example: Lets say the number range is from 100(the lowest) to 1800(the highest). Depending on the number range, a background color will have to be displayed from green-ish, to yellow-ish, orange-ish, and red.
A similar problem I found on stackoverflow is this one
AJAX:how I am displaying the numbers inside of the DIVs
<script type="text/javascript">
$(document).ready(function() {
$('#aht').click(function(){
$.ajax({
type:"GET",
url : "show_aht.php",
data:{ } , // do I need to pass data if im GET ting?
dataType: 'json',
success : function(data){
//going through all DIVs only once with this loop
for(var i = 0; i < data.length; i++) { // loop over results
var divForResult = $('#desk_' + data[i]['station']); // look for div for this object
if(divForResult.length) { // if a div was found
THIS IS WHERE I AM OUTPUTTING THE NUMBER
divForResult.html(data[i]['aht_value']); // set inner HTML with AHT value
}//end if
}//end for
}//end success
});//end ajax
});//end click
});//end rdy
</script>
show_aht.php numbers being retrieved from the array below
$result = array();
foreach ($memo as $username => $memodata) {
if (in_array($username, array_keys($user))) {
// Match username against the keys of $user (the usernames)
$userdata = $user[$username];
//if AHT is null give N/A as value
if (is_null($memodata['aht_value'])) {
$result[] = array( 'username' => $userdata['username'],
'aht_value' => 'NA',
'station' => $userdata['station']
);
}//end inner if
//else give the actual value of AHT without the decimals
else {
$result[] = array( 'username' => $userdata['username'],
'aht_value' => substr($memodata['aht_value'],0,-3),
'station' => $userdata['station']
);
}//end else
}//end outer if
}//end for
echo json_encode($result);