The response is coming through to the browser in the developer tools, but I'm having trouble getting the data from the response that I want into workable form.
app.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"));
}
If I look in the developer console at the data
responseText: "jQuery19105805847404990345_1364409899124 && jQuery19105805847404990345_1364409899124({↵ "pollName": "testPoll",↵ "pollTitle": "Do you like Doritos?",↵ "pollID": "5150a7596a76e6378a000002",↵ "pollOptions": [↵ "Yes",↵ "No",↵ "Maybe"↵ ]↵});"
Which is what I want but neither of the two methods up there work. Any advice?
Instead of data.tostring,try
JSON.stringify( data)