Weedpacket;11009277 wrote:The first argument to [man]printf[/man] should be a format string. Are you missing it, or is it in [font=monospace]$obj->todo[/font]?
Ok, I format the printf statement and the AJAX data returns.
This is my print string:
printf("%s %s %s \n",$obj->todo, $obj->date, $obj->name);
The data returned is my task list:
laundry 0000-00-00 me
chores 0000-00-00 By kids
cook dinner 0000-00-00 me
But it is kind of munged together and it still doesn't get displayed on the web page
because something is wrong with the Jquery each statement see below?
Isn't it better to return the entire object to Jquery data and parse it in the each function?
print_r($obj);
The results in firebug:
stdClass Object
(
[todo] => What needs to be done?
[date] => 0000-00-00
[name] => By whom?
)
stdClass Object
(
[todo] => What needs to be done?
[date] => 0000-00-00
[name] => By whom?
)
stdClass Object
(
[todo] => What needs to be done?
[date] => 0000-00-00
[name] => By whom?
)
So I still need to know how to display this with the Jquery .each function?
To display the name, todo item and the date:
$(document).ready(function() {
$.ajax({
url: 'ajax/get_todosx.php',
dataType : 'json',
success: function(data) {
var list_start ='<li "class" = "todo-list" >';
var list_end ='</li>';
var checkbx ='<input type="checkbox" id="task" checked="false" />';
var delRow ='<input type="button" value="Delete" class="btnDelete" onclick="deleteRow(this)" />';
$('.result').html(data);
alert('Load was performed.');
var rows= ' ';
$.each(data, function(idx,item) {
rows+= list_start + checkbx + item.todo + ', ' + item.name + item.date + delRow +list_end;
$("ul").append(rows);
});
}
});//end document ready
Something is wrong with the item and the index. Should it be i
thanks,