Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7085649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:27:02+00:00 2026-05-28T07:27:02+00:00

I`m starting a project with backbone.js and as you know, my main problem was

  • 0

I`m starting a project with backbone.js and as you know, my main problem was to figure out a good pattern of coding. However, I would like to know how is the best way to handle messages from ajax callbacks (save, destroy, fetch) for example on success without setting all on the model

What I wish to do is separate some data from model and handle it not as attributes, like for example on model.save() callback json:

{ message: "Successful post", post: { id: 13, text: "test" } }

Here is the code:

post = new Post({..})
post.save({}, { 
  success: function(post, xhr) {
     data = jQuery.parseJSON(xhr.responseText)
     alert(data.message)
  }
})

Is there a better way to do it or I have to leave as attribute? Like:

{ message: "Successful post", id: 13, text: "test" }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:27:02+00:00Added an answer on May 28, 2026 at 7:27 am

    You can override the Model parse method to intercept the data from the response.

    In your case you might have something like:

    parse : function(resp, xhr) {
      alert resp.message;
      return resp.post;
    },
    

    So you could keep the same structure in the JSON you return from the server. In your parse method you can do whatever you want with the additional data just so long as you extract the part that represents the model data and return it from the method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm starting a project with MVC 2 and would like to know if the
I am starting a project from scratch using Intersystems Cache. I would like to
I just starting a project, I would like to have a small content manager
We're starting a project right now and we wanted to know what's the best
I'm starting a project which I think would benefit from bindings (I've got a
I'm starting a project that will be public facing using asp.net mvc. I know
I'm starting a project in Visual Studio 2010 and I'd like to use FogBugz
I will be starting a project soon at my company and the client would
I had on old C++ project starting a Console-application. With a breakpoint in main(int
I am starting a project, and plan on keeping strings separated out by using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.