以下の成功コールバック関数をどのようにコーディングして、以下の返された JSON 内のオブジェクトにアクセスできるようにしますか。明らかに、返されたオブジェクトに、を使用してアクセスできなくなりますsuccess: function(data) {if (data.returned === true) {
。どうすればこれを達成できますか?
jQuery コード:
$("#projects").click(function() {
jQuery.ajax({ type: "POST", dataType: "JSON",
url: "<?=base_url()?>index.php/home/projectsSlider",
json: {returned: true}, success: function(data) {
if (data.returned === true) {
$("#resultProjects").html(JSON.stringify(data.Projects));
$("#resultScreenshots").html(JSON.stringify(data.Screenshots));
$("#content").fadeOut(150, function() {
$(this).replaceWith(projectsSlider(data.projectId, data.projectName, data.startDate, data.finishedDate, data.projectDesc, data.createdFor, data.contributors, data.screenshotURI, data.websiteURL), function() {
$(this).fadeIn(150);
});
});
}
}
});
});
返された JSON:
{
"Projects": [
{
"projectId": "932713684f9073189ec7b",
"projectName": "Cloud859Collective",
"startDate": "April 19th, 2012",
"finishedDate": "April 25th, 2012",
"createdFor": "ClasskCreations",
"contributors": "Mike Grigsby",
"projectDesc": "This website was created with a friend in mind. His name is Kevin Johnson and he is a rapper. He needed a website that would allow him to host and share his music."
},
{
"projectId": "10599012654f907093714e9",
"projectName": "Nurbell Studio",
"startDate": "April 15th, 2012",
"finishedDate": "April 19th, 2012",
"createdFor": "Nurbell LLC",
"contributors": "Mike Grigsby",
"projectDesc": "This is the page you are currently looking at. This is the official Nurbell homepage. Complete with a frontend and a backend."
}
],
"Screenshots": [
{
"screenshotURI": "http://nurbell.com/vd/1.0/images/project-data/kevo.png"
},
{
"screenshotURI": "http://nurbell.com/vd/1.0/images/project-data/nurbell.png"
}
]
}