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

  • Home
  • SEARCH
  • 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 516607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:44:55+00:00 2026-05-13T07:44:55+00:00

I’m about to make a web app which will have a pretty heavy client

  • 0

I’m about to make a web app which will have a pretty heavy client end. I’m not sure about the way to organize my javascript code, but here is a basic idea :

// the namespace for the application
var app = {}; 

// ajax middle layer
app.products = {
  add : function(){
    // send ajax request 
    // if response is successful
       // do some ui manipulation
       app.ui.products.add( json.data );
  },
  remove : function(){},
  ... 
};
app.categories = {
  add : function(){},
  ....
};

// the ui interface which will be called based on ajax responses
app.ui = {};
app.ui.products = {
  add : function( product_obj ){
     $('#products').append( "<div id='"+product_obj.id+"'>"+product_obj.title+"</div>" );
  }
};
app.ui.categories = {};

Anybody got similar experiences to tell me the pros and cons of this approach? What’s your way of designing client side javascript code architecture? Thanks.

[update] : This web app, as you see from the above, deals with products CRUD, categories CRUD only in a ajax fashion. I’m only showing an snippet here, so you guys know what I’m trying to achieve and what my question is. Again, I’m asking for inputs for my approach to organize the code of this app.

  • 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-13T07:44:56+00:00Added an answer on May 13, 2026 at 7:44 am

    That is similar to the way I do my JavaScript projects. Here are some tricks I have used:

    • Create one file for each singleton object. In your code, store ajax, middle layer and ui interface in separate files
    • Create a global singleton object for the 3 layers usually in the project; GUI, Backend and App
    • Never use pure ajax from anywhere outside the Backend object. Store the URL to the serverside page in the Backend object and create one function that uses that URL to contact the server.
    • Have a JSON class on the server that can report errors and exceptions to the client. In the Backend object, check if the returned JSON object contains an error, and call the serverError function in the GUI class to present the error to the user (or developer).

    Here is an example of a Backend object:

    var Backend = {};
    Backend.url = "/ajax/myApp.php";
    Backend.postJSON = function(data, callback){
      var json = JSON.stringify(data);
      $.ajax({
        type: "POST",
        url: Backend.url,
        data: "json="+json,
        dataType: "json",
        success: function(response){
          if(response){
            if(response.task){
              return callback(response);
            }else if(response.error){
              return Backend.error(response);
            }
          } 
          return Backend.error(response);
        },
        error: function(response){
          Backend.error({error:"network error", message:response.responseText});
        },
      });
    };
    Backend.error = function(error){
      if(error.message){
        Client.showError(error.message, error.file, error.line, error.trace);
      }
    };
    

    This can be improved by storing the ajax object somewher in the Backend object, but it’s not necessary.

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

Sidebar

Ask A Question

Stats

  • Questions 251k
  • Answers 251k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I have not used django-cms so this is just off… May 13, 2026 at 9:27 am
  • Editorial Team
    Editorial Team added an answer You must use string for the mapped property. You can,… May 13, 2026 at 9:27 am
  • Editorial Team
    Editorial Team added an answer You need to put the name and the score together… May 13, 2026 at 9:27 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want use html5's new tag to play a wav file (currently only supported
I've got a string that has curly quotes in it. I'd like to replace
In order to apply a triggered animation to all ToolTip s in my app,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.