I am making a POST to the server, which returns an object.
The object is JSON and looks like this;
Object {yourVote: 7, totalVotes: 41, average: "6.9"}
I want to get the text and values from this object and use them in my html - give them classes, color, etc.
How would i go about achieving that?
So far, i have tried fetching the text of the object using .txt() but that returns an error of undefined. I have also tried converting that JSON object to an array so i can access its values that way but, alas, that returns an error again.
Here is my code:
My AJAX request:
$.ajax({
dataType: "JSON",
type: "GET",
url: "/api/phometervote",
data: {
articleId: articleId,
vote: userVote
},
success: function (rn) {
var message = rn,
messageContent = message.makeArray();
// I would like to be able to access the object as an array
//So that way i can access each item individually
//This returns an error
$(".someClass").html(messageContent[0]);
}
});