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 9114197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:08:46+00:00 2026-06-17T04:08:46+00:00

I have a Backbone model that is making a successful server request. The callback

  • 0

I have a Backbone model that is making a successful server request. The callback is using backbone’s trigger method to trigger an event in the associated view, and its passing the parsed json response from the server request as the second parameter of the trigger method, as described in the backbone documents. In the view, the event triggers the render method, but the response object is null in the view. It’s throwing this error

Uncaught TypeError: Cannot read property 'word' of null 

Can anyone see what I might be doing wrong?

The server request from the model

  new: function() {
      var _this = this;
       console.log("new function of model"); 

      $.ajax({
        url: "/gamestart",
        type: "GET",
        success: function(response) {
          console.log(response);
          var json = $.parseJSON(response);

          _this.set({lost: false});
          _this.set({win: false});
          _this.trigger("gameStartedEvent", json);
        }
      })
    },

the event in the initializer method of the view which triggers the render method to render the response

this.model.on("gameStartedEvent", this.render, this);

the render method where the response is null

render: function(response) {
      $("#hint").show();
      console.log(response); 
      var html = this.template({characters: response.word});
      this.el.hide();
      this.el.html(html).show();
    },

Note, if it matters, the view is being instantiated with the model

var word_view = new WordView({model: game})

Update

Actually the error’s happening here. The response is returning successfully but i’m parsing it incorrectly. The variable json is null when I check the console. Can you see what I’m doing wrong?

 var json = $.parseJSON(response);
 console.log(json)

Response

Object {word: Array[6]}
word: Array[6]
__proto__: Object
  • 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-06-17T04:08:47+00:00Added an answer on June 17, 2026 at 4:08 am

    There was actually no need to call parseJSON on the response object. I could get the word property directly off the response object, so I just passed the response object as the second argument to trigger, and called response.word in the view.

     $.ajax({
            url: "/gamestart",
            type: "GET",
            success: function(response) {
              console.log(response.word);
              var json = $.parseJSON(response);    ####unnecessary to parseJSON here
              console.log(json);
    
              _this.set({lost: false});
              _this.set({win: false});
              _this.trigger("gameStartedEvent", response);
            }
          })
        },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using handlebars.js templates with backbone.js. Have a view connected to a model that contains
I have a Backbone View that has a Collection as its Model. If the
I've got a backbone view model that I'm rendering here and making it draggable
Assume that I have a backbone model that has a bunch of boolean attributes:
I'm having an issue with backbone.js' models. I have a view that creates another
I have two backbone models, loaded from server: var Model = Backbone.Model.extend({}); var SubModel
I have this model var Item = Backbone.Model.extend({ url: 'http://localhost/InterprisePOS/Product/loaditembycategory/Event Materials' }); var onSuccess
I use backbone.js and have a model without a collection. In the view I
I have a models.DateTimeField() field in my django model. I am using backbone to
I have a backbone model that looks somewhat like this: var myModel = Backbone.Model.extend({

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.