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

The Archive Base Latest Questions

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

I am experimenting with a modular AJAX design where a script is returned to

  • 0

I am experimenting with a modular AJAX design where a script is returned to process and display payload. I currently have the following JSON response working but I would like some advice in terms of structuring the application to support this in a more maintainable way.

{
    payload: "<div class=\"test\">Something</div>",
    load: "jQuery(this.payload).appendTo('body')"
}

To generate the “load” script I have considered:

  • Pass all dynamic variables via this and loading a fixed JavaScript from server

    jQuery(this.payload).appendTo(this.appendTo)
    
  • Replace special templates within JavaScript with dynamic content:

    jQuery(this.payload).appendTo('{{APPENDTO}}')
    
  • Or perhaps there would be a better methodology?

  • 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-27T09:21:03+00:00Added an answer on May 27, 2026 at 9:21 am

    Before I have had the following structure;

    [
        {
            args: ["<div class=\"test\">Something</div>"],
            method: "appendTo",
            selector: "body"
        },
        ...
    ]
    

    Which you could then do as;

    var foo = JSON.parse(theJSON);
    
    for (var i=0;i<foo.length;i++) {
        var curr = foo[i];
        jQuery.fn[method].apply($(curr.selector), curr.args);
    }
    

    This supports the most common DOM methods, but can also support remove(), empty() etc;

    [
        {
            args: [],
            method: "remove",
            selector: ".someElement"
        },
        ...
    ]
    

    If this is still too stringent, you should look at skipping JSON completely, and just inserting the response into your page as a <script> tag.

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

Sidebar

Related Questions

I'm currently experimenting with build script, and since I have an ASP.net Web Part
I am currently experimenting with various input controls and have stumbled upon SneakyInput, which
I have been experimenting with woopra.com A web analytics tool. Which requires a piece
While experimenting with iPhone app development, we have several AppIDs which should be deleted
I am experimenting with following code: http://www.jsresources.org/examples/MidiNote.java.html to operate my Novation Launchpad MIDI Controller.
Experimenting with Cocos2D collection detection and have some questions. First, some background: This is
I experimenting with Flex Styling, and I came across an alignment issue. I have
I've been experimenting with the standard python math module and have come across some
been experimenting with unordered list UL and i have seem varios examples of using
Im experimenting with the following code private void timer1_Tick(object sender, EventArgs e) { Thread

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.