I am getting a valid JSON object from the form handler. The problem is I get this error on the AJAX result:
I get the 200 status then I get Syntax ERror: JSON parse: unexpected charACTER.
This is part of the JSON object:
Success... Localhost via UNIX socket [{"todo":"","date":"0000-00-00","name":"","id":"609"},{"todo":"","date":"0000-00-00","name":"","id":"608"},{"todo":"","date":"0000-00-00","name":"","id":"607"},{"todo":"ff","date":"0000-00-00","name":"ff","id":"611"},{"todo":"wash car","date":"0000-00-00","name":"Janis Rough","id":"610"},{"todo":"shopping","date":"2013-01-04","name":"Janis Rough","id":"627"},{"todo":"shopping","date":"2013-01-04","name":"Janis Rough","id":"626"},{"todo":"car wash","date":"2013-01-04","name":"Janis Rough","id":"625"},{"todo":"do laundry","date":"2013-02-14","name":"janis rough","id":"633"},{"todo":"do laundry","date":"2013-02-14","name":"janis rough","id":"632"},{"todo":"do laundry","date":"2013-02-14","name":"janis rough","id":"631"},{"todo":"do laundry","date":"2013-02-14","name":"janis rough","id":"630"}]
Here is the code:
$(document).ready(function() {
$.ajax({
url: 'form_handler_copy1.php',
dataType : 'json',
success: function(data) {
var list_start ='<li class = "todo-list" >';
var list_end ='</li>';
var checkbx ='<input type="checkbox" id="task" /> ';
var tblHdr = '<table class="table">';
tblHdr +="<tr> <th>Todo Item</th><th>Task Assigned To</th><th>Date Due</th></tr>";
var delRow = '<input type="button" class="btnDelete" onclick="deleteRow(this)" ></input>';
var tblEnd = "<\table>";
var rows= '';
$.each(data, function(idx,item) {
rows+=
'<tr><td>'+checkbx +item.todo +'</td><td>'+item.name+'</td><td>'+item.date + delRow + '</td></tr>';
$("#response").append(rows);
});//end each
},
//end success
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
}); //end AJAX