I have the following JSON coming back:
{"gameId":137.0,"memberId":3,"id":97.0,"reviewBody":"Great game! Awesome.","createdAt":"October, 13 2010 18:55:34"}
I'm trying to append it to a layer using the following JavaScript, but nothing is showing:
$(function(){
$(".review-form").submit(function(){
dataString = $(".review-form").serialize();
$.ajax({
type: "POST",
url: "#URLFor(controller="membros", action="createReview")#",
data: dataString,
dataType: "JSON",
returnFormat: "JSON",
success: function(response) {
$(".review-confirmation").html(response.REVIEWBODY);
$('.review-form').slideToggle('slow', function() { });
}
});
return false; // keeps the normal request from firing
});
});
I've tried using uppercase, lowercase, and camel-case for response.reviewBody, but nothing was showing. Any ideas where I'm going wrong?开发者_StackOverflow中文版
Surprisingly,
dataType: "JSON",
in upper case will not return JSON data.
You need to use
dataType: "json",
精彩评论