To fix your code:
$.ajax({
type: "POST",
dataType: "JSON",
url: "index.php",
success: function(data) {
console.log(data); //test to see if we get something back
for (var i = 0; i < data.length; i++) {
console.log(data[i]['1_assigned_accepted']);
}
}
});
The difference OP and mine is assignment of i=0; -> var i = 0; and using brackets for getting the value.
Some Notes:
When doing a post you usually send data using the data: option. (remember to Json.stringify(input)). When posting you may need more options:
function postJson(url, data, successCallback, errorCallback) {
$.ajax({
url: url,
type: 'POST',
data: JSON.stringify(data),
contentType: 'application/json',
dataType: 'json',
success: successCallback,
error: errorCallback
});
}
Notice there's contentType, dataType and data being used here. You usually want all of these when doing a post.
Invoke like so:
var data = { name: 'Rhys' };
postJson(
'index.php',
data,
function(responseData) {
console.log(responseData);
},
function(err) {
console.error(err);
}
);
Another point:
You are assuming that your response object is an array, you could test using instanceof.
I hope this helps,
Rhys
index.phpreturnsassigned_accepted_1and it should start working for you.