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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:10:05+00:00 2026-06-14T01:10:05+00:00

My scenario is this – the user asks for the home page and then

  • 0

My scenario is this – the user asks for the home page and then the javascript code of the page executes an ajax GET request to the same server to get some object.

The server keeps the home page as a jade template.

So, right now it takes two roundtrips to load the home page:

  1. GET the home page
  2. GET the JSON object

I am OK with it, but just out of curiosity – what are my options to incorporate the object requested later into the initial GET request of the home page?

I see one way is to have a hidden html element, which inner HTML would be the string representation of the object. A bit awkward, but pretty simple on the server side, given that the home page jade template is preprocessed anyway.

What are my other options?

Please, note that I am perfectly aware that sparing this one roundtrip does not really matter. I am just curious about the techniques.

  • 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-14T01:10:06+00:00Added an answer on June 14, 2026 at 1:10 am

    Another option is to always return a JSON object, then the HTML for your home page would be the value of some property on this object. This would probably require some changes on your client-side logic, though.

    One more option: instead of a hidden HTML input/textarea containing a JSON string, the home page code could contain a script block where an object literal is declared as a variable. Something like this:

    <script>
    var myObj = ... // Your JSON string here.
                    // myObj will be an object literal, and you won't need
                    // to parse the JSON.
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario 1 This involves using one gateway route in app.yaml and then choosing the
In this scenario I have an app in which: The user is to log
Consider this scenario. I have some business logic that now and then will be
Consider this scenario: Using Javascript/E4X, in a non-browser usage scenario (a Javascript HL7 integration
I have this code in my javascript view model using Knockout. Everything works as
Consider the following scenario (this is not production code): class MyClass { public function
I have this scenario: class A { public virtual int Id { get; set;
Supose this Scenario public class CustomerMetaData { [DataType(DataType.EmailAddress)] public String EmailAddress {get;set;} [DataType(DataType.Url)] public
Consider this scenario: <asp:CheckBoxList> in a master page. the goal is to have all
Assuming this scenario- A user downloads a zip file A after in app purchase

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.