开发者

Unable to append content coming back in JSON

开发者 https://www.devze.com 2023-01-20 08:40 出处:网络
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 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",
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号