parsing success callbacks from ajax call
I have a backbone object that I'm calling save on. How do I know what
comes back in the ajax call. Looking at the code for the project I got put
on, I see some people just have a generic
success: function (data) {
console.log(data);
Then other times, I see:
success: function (library, response) {
console.log(library);
console.log(response)
I'm confused on how you would know you would have I presume a library or
response object, vs a general data. When I look at the second example, I
am looking at the output of
console.log(response);
and I see response has three attributes:
Notifications
Response
ResponseStatus
Response itself looks like Object {Id="12345", href="the/href", Name="asdf"}
So it looks like a Javascript object to me, but then when I try to do
console.log(response.Name);
I always get undefined even though I can see the value.
So I'm trying to understand how the callback in an ajax calls. Like when
you can use an actual library object, response object, vs a data object,
and how I can go about parsing the results properly. Thanks in advance!
No comments:
Post a Comment