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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:59:38+00:00 2026-05-18T23:59:38+00:00

I am setting the innerHTML variable of a div with contents from an ajax

  • 0

I am setting the innerHTML variable of a div with contents from an ajax request:

new Ajax.Request('/search/ajax/allakas/?ext_id='+extid,
  {
    method:'get',
    onSuccess: function(transport){
      var response = transport.responseText || "no response text";
      $('admincovers_content').innerHTML=response;
    },
    onFailure: function(){ alert('Something went wrong...') }
  });

The response text cotains a form:

    <form id="akas-admin" method="post" action="/search/ajax/modifyakas/">
        <input type="text" name="formfield" value="i am a form field"/>
    </form>

Then I call a functiont that should submit that form:

$('akas-admin').request({
  onComplete: function(transport){ 
      //alert('Form data saved! '+transport.responseText)
        $('admincovers_content').innerHTML=transport.responseText;
      }
});

The problem is $('akas-admin) returns null , I tried to put the form with this id in the original document, which works.

Question: Can I somehow “revalidate” the dom or access elements that have been inserted with innerHTML?

Edit Info: document.getElementById("akas-admin").submit() works just fine, problem is i don’t want to reload the whole page but post the form over ajax and get the response text in a callback function.

Edit:

Based on the answers provided, i replaced my function that does the request with the following observer:

Event.observe(document.body, 'click', function(event) {
  var e = Event.element(event);
  if ('aka-savelink' == e.identify()) {
      alert('savelink clicked!');
      if (el = e.findElement('#akas-admin')) {
        alert('found form to submit it has id: '+el.identify());
        el.request({
            onComplete: function(transport){ 
            alert('Form data saved! '+transport.responseText)
                $('admincovers_content').innerHTML=transport.responseText;
            }
        });
      }
  }
});

problem is that i get as far as alert('savelink clicked!'); . findelement doesnt return the form. i tried to place the save link above and under the form. both doesnt work.
i also think this approach is a bit clumsy and i am doing it wrong. could anyone point me in the right direction?

  • 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-18T23:59:38+00:00Added an answer on May 18, 2026 at 11:59 pm

    So $('akas-admin') returns null but document.getElementById("akas-admin") does not. The $ function is mostly just a wrapper for document.getElementById so it’s unusual for this to break down. Have you tried using Element.extend(document.getElementById('akas-admin'))?

    Do you have any other libraries loaded? Can you recreate the problem in jsFiddle?

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

Sidebar

Related Questions

Ok, so the base problem is in setting the innerHTML of a div element,
If i am setting the contents of a DIV element in my dom: $(#myE).html(contents);
I am making an Ajax POST Request and it does not get recognized in
Setting up new git installations. On one Windows laptop, I'm running (under cygwin): git
Setting up environment variables for hundreds of tests get old very quick. Is there
Found this method of having DIV as custom google maps infoWindow. It works, but
I am setting the innerHTML property of document element within this way: document.getElementById('some_element').innerHTML =
Is it possible to determine when setting an innerHTML has loaded? I'm not sure
Currently I'm working on setting up a basic WebSockets script. I can get the
I'm using Prototype's PeriodicalUpdater to update a div with the results of an ajax

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.