Hi guys,
I am making an Ajax call to a PHP that get some data from a MYSQL table and out puts the result:
if ($result = mysqli_query($mysqli, $query5)) {
$out = array();
while ($row = $result->fetch_assoc()) {
$out[] = $row;
}
}
/* encode array as json and output it for the ajax script*/
echo json_encode($out);
I get what I believe is a JSON array returned with :
btnGetFile.onclick = function() {
req = Ajax("ajaxGetURL.php/?urlToGet=" + txtURL.value, done);
};
function done() {
if (req.status == 200) { //success
htmResponse.innerHTML = req.responseText;
var data = req.responseText;
// loop through the array
for(var i in data)
{
var text =data[i].InvID;
alert(text);
var choic=data[i].CustID;
var output='<li>'+text+'</li>';
}
$('#List1').empty().append(output);
} else { //failure
msg = "Error: Status = " + req.status;
if (TypeName(req.statusText) == "string") {
msg = msg + " " + req.statusText;
}
if (TypeName(req.err) == "string") {
msg = msg + " " + req.error;
}
NSB.MsgBox(msg);
}
}
List1.onclick=function(i){
if(typeof i == "object") return;
alert("Menu item chosen: " + i + " " + List1.getItem(i));
}
I am getting undefined.
The app is at AjaxGetWebFile
Once I have this bit working I then need to populate the list with some of the data in the array.
What am I doing wrong here please.
Cheers
Steve Warby