I am using the Chrome Debugger, and can see that I am correctly getting the JSON feed from the AJAX request (PHP File -> Page). The issue is taking the data from that feed, and inserting it into the table mentioned below. The part that confuses me most, is that this code (nearly exactly the same) works perfectly on another part of the site, but doesn't seem to work here.
JSFiddle: http://jsfiddle.net/2qc01ceL/
HTML:
<div class="form_head">Flight & Duty</div>
<table cellpadding="4" cellspacing="0" width="100%">
<thead>
<tr class="tab_head" style="color:#FFF; text-align:center"><th rowspan="2">Pilot</th><th rowspan="2">ARN</th><th colspan="2">Remaining Duty Time</th><th colspan="3">Remaining Flight Time</th></tr>
<tr class="tab_head" style="color:#FFF; text-align:center"><th>7 Day</th><th>14 Day</th><th>7 Day</th><th>30 Day</th><th>365 Day</th></tr>
</thead>
<tbody>
<tr><td id="name"></td><td id="arn"></td><td></td><td></td><td></td><td></td><td></td></tr>
</tbody>
</table>
JQuery/AJAX:
$(document).ready(function() {
var data = function(callback) {
return $.ajax({
type: "GET",
dataType: 'json',
url: "required/duty.php",
async: false,
success: function(doc) {
var duty = [];
$(doc).each(function() {
duty.push({
id: $(this).attr('id'),
dutyarn: $(this).attr('dutyarn'),
dutyon: $(this).attr('dutyon'),
dutyoff: $(this).attr('dutyoff'),
dutytime: $(this).attr('dutytime'),
userfname: $(this).attr('userfname'),
userlname: $(this).attr('userlname'),
});
});
callback(duty);
}
}).responseText;
};
document.getElementById("arn").innerHTML = duty.arn;
});
PHP File:
mysql_connect(
"mysql.**.com",
"**",
"**") or die
("Unable to connect to SQL server");
mysql_select_db(
"**") or die
("Unable to select database");
$json = array();
$get_duty = "
SELECT * FROM heli_duty
LEFT JOIN heli_user ON duty_arn = user_arn
WHERE 1";
$run_duty = mysql_query("$get_duty") or die($sql_error .mysql_error());
$duty_array = array();
while ($duty = mysql_fetch_assoc($run_duty, MYSQL_ASSOC)) {
$duty_array[] = array(
'id' => $duty[duty_id],
'dutyarn' => $duty[duty_arn],
'dutyon' => $duty[duty_on],
'dutyoff' => $duty[duty_off],
'dutytime' => $duty[duty_time],
'userfname' => $duty[user_fname],
'userlname' => $duty[user_lname],
);
}
echo json_encode($duty_array);