0

响应正在通过开发人员工具中的浏览器传递,但我无法从我想要的响应中获取数据,并将其转换为可行的形式。

应用程序.js

res.jsonp({
                pollName: loadedPoll.pollName,
                pollTitle: loadedPoll.pollTitle,
                pollID: loadedPoll._id,
                pollOptions: loadedPoll.pollOptions
            });

javascript

    $.ajax({
        url: 'http://Thisiscorrect.com:3000/loadPoll',
        dataType: 'jsonp',
        data:{questionName: 'testPoll'},
        success: function(data){ //console.log(data);
            var X = data.toString();

            console.log(X);
            //console.log($(x).filter("#responseText"));
        }

如果我在开发者控制台中查看数据

responseText: "jQuery19105805847404990345_1364409899124 && jQuery19105805847404990345_1364409899124({↵ "pollName": "testPoll",↵ "pollTitle": "Do you like Doritos?",↵ "pollID": "5150a7596a76e6378a000002",↵ "pollOptions": [↵ "Yes",↵ "No",↵ "Maybe"↵ ]↵});"

这就是我想要的,但上面的两种方法都不起作用。有什么建议吗?

4

1 回答 1

1

代替 data.tostring,试试

JSON.stringify( data)
于 2013-03-27T19:22:06.167 回答