[jQuery] JSON Help?
[jQuery] JSON Help?
I think my generated json code is messed up, but for the life of me, I
can't see it. In *some* cases, my $.ajax() call process the results
properly, in others it triggers the Error callback, but doesn't actually
have an error. I've asked about this before and the responses I got
then aren't helping right now. Hopefully I'm just blind.
I've posted the code in question below, as well as the resulting JSON,
and a formatted version of the JSON as well. This JSON code works fine
when I plug it into a Javascript variable manually. (Some sections of
the $.ajax() call have been snipped for brevity - these snipped sections
are not causing grief though)
It might be that it's late and I've got tunnel vision, but I can't see
why this isn't working. Any tips are appreciated.
Shawn
Here's the $.ajax() call:
-------------------------
$("#filtertable #filter").click(function () {
var p = "&oid=" + $("#client_id").val();
//other code snipped for building up the parameter string
$.ajax({
type: "post",
url: "xhr/filter.php?r=" + Math.random(),
data: p,
dataType: "json",
success: function (json) {
//code to build a table goes here //
$("#filterResults").html(myTable);
},
error: function (a,b,c) {
$("#filterResults").text(a.responseText);
//$("#msg").html(a.responseText).slideDown("slow");
}
});
return false;
});
Here's a sample of the JSON results that are not working:
-----------------------------------------------------------
([ { id: "124", organization: "XYZ Corp", start: new Date("2007-09-30
13:30:00"), end: new Date("2007-09-30 19:00:00"), duration: 5.5,
worktype: "Programming", project: "Projext X", description: "Scans.
Fixed a number of reported problems, and some un-reported issues.
Cleaned up the table sorting, and added sort direction indicators.
Created an \"eye\" image for the view icon (replacing the disk icon).
Fixed the file path so that it actually had a path on the search
results. Files can now be opened from the search results (when using IE
on the local network). Fixed the update routine that was badly broken
(but not reported yet). Moved the search results into separate tabs for
each job type. Tested the site in IE - took some time tracking down an
IE specific bug. Records are loading fine if there is a location record
(which is now required, so old testing data could be troublesome).
Changed the menu as requested to put Scans under the Job Search menu
item. Tried to upload, VPN problems prevented this. Will talk with
Norm.", billed: null }, { id: "123", organization: "XYZ Corp", start:
new Date("2007-09-16 12:00:00"), end: new Date("2007-09-16 17:00:00"),
duration: 5, worktype: "Programming", project: "Projext X", description:
"Fixed up the remaining interface issues with Scanned Jobs. The search
results are now listing things as they should, and the files can be
viewed from the results list, or the record could be edited. Added
sortable table columns to the search results. Fixed the load routine to
properly populate a job when selecting one from the search results.
Changed the menu item to \"Scanned Jobs\" from \"Unregistered Jobs\".
Uploaded the changes to the live server, notified Norm.", billed: null
}, { id: "122", organization: "XYZ Corp", start: new Date("2007-09-09
12:00:00"), end: new Date("2007-09-09 17:00:00"), duration: 5, worktype:
"Programming", project: "Projext X", description: "Continued on Scanned
Jobs. Fixing the save routine for multiple columns. The bit mask should
mean we have one record for all quarters\/sections in the same twp, but
we are getting one record for EACH quarter in the twp. Fixed this by
moving the bit mask processing into JavaScript, rather than CF and\/or
SQL.", billed: null }, { id: "95", organization: "XYZ Corp", start: new
Date("2007-09-04 19:10:00"), end: new Date("2007-09-04 23:10:00"),
duration: 4, worktype: "Programming", project: "Projext X", description:
"Scanned Jobs. Got the interface to handle multiple locations
functioning properly. Moving to other townships clears the grid, and
selects any existing selected locations in the new
township\/range\/meridian. Got the interface to highlight the
corresponding location in the location list when the grid is hovered
over, or in the grid when the location list is hovered over. Set the
township text box to have focus when the page is loaded.", billed: null } ])
And the same JSON code formatted a little better
------------------------------------------------
(
[
{
id: "124",
organization: "XYZ Corp",
start: new Date("2007-09-30 13:30:00"),
end: new Date("2007-09-30 19:00:00"),
duration: 5.5,
worktype: "Programming",
project: "Projext X",
description: "Scans. Fixed a number of reported problems, and
some un-reported issues. Cleaned up the table sorting
, and added sort direction indicators. Created an
\"eye\" image for the view icon (replacing the disk
icon). Fixed the file path so that it actually had
a path on the search results. Files can now be
opened from the search results (when using IE on the
local network). Fixed the update routine that
was badly broken (but not reported yet). Moved the
search results into separate tabs for each job type
. Tested the site in IE - took some time tracking
down an IE specific bug. Records are loading fine
if there is a location record (which is now
required, so old testing data could be troublesome). Changed
the menu as requested to put Scans under the Job
Search menu item. Tried to upload, VPN problems prevented
this. Will talk with Norm.",
billed: null
},
{ id: "123",
organization: "XYZ Corp",
start: new Date("2007-09-16 12:00:00"),
end: new Date("2007-09-16 17:00:00"),
duration: 5,
worktype: "Programming",
project: "Projext X",
description: "Fixed up the remaining interface issues with Scanned
Jobs. The search results are now listing things as
they should, and the files can be viewed from the
results list, or the record could be edited. Added
sortable table columns to the search results. Fixed
the load routine to properly populate a job when
selecting one from the search results. Changed the
menu item to \"Scanned Jobs\" from \"Unregistered
Jobs\". Uploaded the changes to the live server,
notified Norm.",
billed: null
},
{
id: "122",
organization: "XYZ Corp",
start: new Date("2007-09-09 12:00:00"),
end: new Date("2007-09-09 17:00:00"),
duration: 5,
worktype: "Programming",
project: "Projext X",
description: "Continued on Scanned Jobs. Fixing the save routine
for multiple
columns. The bit mask should mean we have one
record for all quarters\/sections in the same twp, but
we are getting one record for EACH quarter in the
twp. Fixed this by moving the bit mask processing
into JavaScript, rather than CF and\/or SQL.",
billed: null
},
{
id: "95",
organization: "XYZ Corp",
start: new Date("2007-09-04 19:10:00"),
end: new Date("2007-09-04 23:10:00"),
duration: 4,
worktype: "Programming",
project: "Projext X",
description: "Scanned Jobs. Got the interface to
handle multiple locations functioning properly.
Moving to other townships clears the grid, and selects
any existing selected locations in the new
township\/range\/meridian. Got the interface to highlight
the corresponding location in the location list when
the grid is hovered over, or in the grid when the
location list is hovered over. Set the township
text box to have focus when the page is loaded.",
billed: null
}
]
)