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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:08:49+00:00 2026-05-26T03:08:49+00:00

I just downloaded MooTools 1.4. I’m having trouble connecting a button click to the

  • 0

I just downloaded MooTools 1.4. I’m having trouble connecting a button click to the launching of an AJAX request. In my page below, I have a button with id=”submit”, but clicking the button doesn’t trigger the alert …

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Test</title>
<script type="text/javascript" src="js/mootools-core-1.4.1-full-compat.js"></script>
<script type="text/javascript">
    /* ajax alert */
    $('submit').addEvent('click', function(event) {
        alert("hello");
        var filename = $('filename').value;
        //prevent the page from changing
        event.stop();
        //make the ajax call
        var req = new Request({
            method: 'get',
            url: '/renderhtml/' + filename,
            data: { },
            onRequest: function() { 
            // on request
        },
        onComplete: function(response) { 
            $('content').set('html',response);
        }
        }).send();
    }); 
</script>
</head>
<body>

    <div>
        <form name="f">
            File name: <input type="text" size="25" id="filename" name="filename" value="" />
            <input type="button" id="submit" name="submit" value="Submit" />
        </form>
    </div>
    <div id="content"></div>

</body>
</html>

I have confirmed the mootools source file is in the right place. What else am I missing? Thanks, – Dave

  • 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-26T03:08:49+00:00Added an answer on May 26, 2026 at 3:08 am

    You should use the domready event on the window, or place the script tag below the button in the HTML. (preferably all the way down the body)

    You’re trying to access the button with id submit while the page is still loading, so the button doesn’t exist yet. However, when you execute the code on the domready or maybe load event, you can be sure that the whole page is loaded and dom manipulation can be done.

    window.addEvent('domready', function() {
      // Your code
    });
    

    ^ waits for the page to load before it does anything.

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

Sidebar

Related Questions

I just downloaded the Haskell and J modes off of SourceForge, and I'm having
I just downloaded Scrapy (web crawler) on Windows 32 and have just created a
I just downloaded newsest doc list api, and have a try. My code as
Just downloaded IE9 and pulled up a webproject i have with an IHttpHandler that
I just downloaded the SWT examples from the Eclipse site but I have a
I just downloaded a website template that is in a .PSD form. I have
Just downloaded the Visual Studio 2010 Premium and realized that can't compile the project,
I just downloaded Eclipse several hours ago, and needed to add Java3D to the
I just downloaded the ASP.NET MVC beta and wanted to walk through the quickstarts
I just downloaded MVC and I am going through a tutorial. Everything goes fine

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.