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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:18:36+00:00 2026-06-02T23:18:36+00:00

I’m unable to load plain HTML into a dynamically created DIV element. My script

  • 0

I’m unable to load plain HTML into a dynamically created DIV element. My script looks as follows:

$("button").click(function () {
  var divElem = $('<div />').load('@Url.Action("MyFunkyPartialView", "Home")');
});

MyFunkyPartialView action method returns a partial view that looks as follows:

  • 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-02T23:18:37+00:00Added an answer on June 2, 2026 at 11:18 pm

    Where does your newly created DIV element go?

    When you create an HTML element (i.e. $('<div/>')), that’s not automatically inserted into the document, so you can’t see it on the screen yet. You’ll have to specify where you want to put it.

    It is, however, already in memory, so you can already manipulate it and do stuff to it, including adding content to it as you’re doing. Nothing wrong with your call to .load().

    Long story short then, is that you’re doing nothing wrong — you’re just missing a step in your workflow.

    The only thing you have to do, then, is to insert the DIV to your document. You can do that using something like:

    var divElem = $('<div/>').load('@Url.Action("MyFunkyPartialView", "Home")');
    // ...
    divElem.appendTo('#main');
    

    This adds the DIV element inside the #main element, after all it’s original content.

    EDIT

    When accessing the DIV‘s contents, we have to make sure that the .load() call has had a chance to complete first. Normally this is best achieved through the complete callback.

    var divElem = $('<div/>')
        .load('@Url.Action("MyFunkyPartialView", "Home")', function () {
            // this function executes after the load AJAX call completes,
            // so this is the best place to access the contents of the div.
            alert(divElem.html());
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am unable to load an XML file into a JavaScript Document in Google
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php53/modules/mailparse.so' - /usr/lib64/php53/modules/mailparse.so: cannot open
I renamed the class classBattle to Game and not I get Unable to load
I'm unable to get this jquery statement to work on page load but it
I have been unable to find any decent documentation on this function. The code
I have to load XML from external domain, so my code looks like this
I am working on an application which needs to load fonts dynamically based upon
I am unable to load Xdocument.Load I am unable to load Xdocument.LoadI am unable
error_log shows the following line on startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20060613/memcache.so' -
I run php test_code.php I get PHP Warning: PHP Startup: Unable to load dynamic

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.