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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:45:05+00:00 2026-06-15T12:45:05+00:00

The below executes without errors, but the DOM isn’t updated. var Cart = function()

  • 0

The below executes without errors, but the DOM isn’t updated.

var Cart = function() {
  var $cart;

  function init() {
    $cart = $("#cart");

    this.refresh();
  }

  function refresh() {
    $.ajax({
      // ...
      success: function(html) {
        $cart.html(html); // $cart seems to exist as JS object, but #cart doesn't get updated in the DOM.
        $("#cart").html(html); // This works!
      }
    });
  }

  return {
    init: init,
    refresh: refresh
  }
}();

$(function() {
  Cart.init();
});

Update

I wasn’t actually calling Cart.init() inside the jQuery ready event contra to what the code above says.

  • 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-15T12:45:07+00:00Added an answer on June 15, 2026 at 12:45 pm

    Check your #cart object exists when you call Cart.init(). That’s the only difference I see between your two working and not working code as there is no other problem (see fiddle).

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

Sidebar

Related Questions

Below is my simple Sendmail script. while running, it executes without any error ..
This is with reference to the below question: Execute program from within a C
on $(document).ready(function() in index.php, the below AJAX is executed, running the file getData.php: if
I'm not 100% sure I'm doing this right, but I think I've found an
I'm getting the below error: Started by user anonymous Checkout:workspace / /var/lib/hudson/jobs/test2/workspace - hudson.remoting.LocalChannel@1e77243d
I've got an ajax call via jquery that executes without error until I get
I'm surprised that this hasn't come up before but I haven't found anything in
This seems to be like a common use case... but somehow I cannot get
I have installed DBD::Pg version 2.17.1 but still still getting error while using below
When compiling a program containing this particular function, /* * Function read_integer * *

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.