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

  • Home
  • SEARCH
  • 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 62685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:30:53+00:00 2026-05-10T18:30:53+00:00

I have a simple HTML. I am using the JQuery for AJAX purpose. Now,

  • 0

I have a simple HTML. I am using the JQuery for AJAX purpose. Now, I want to put my javascript function in a separate javascript file. What is the syntax for this? For example, currently my script section in the HTML is something like this:

<script> <script type='text/javascript' src='scripts/scripts.js'></script> <script type='text/javascript' src='scripts/jquery.js'></script> <script type = 'text/javascript' language='javascript'>  $(document).ready(function() {    $('#SubmitForm').click(Submit());  }); </script> 

But I want to put the function

function() {    $('#SubmitForm').click(Submit());  }) 

in the file scripts.js. Can I use assign a name to that function and refer to it?

EDit: I still have a bit of problem here: I changed the code to

<script type = 'text/javascript' language='javascript'> $(document).ready(function() {     $('#SubmitForm').click(submitMe); }); </script> 

and in a separate js file, I have the following code:

var submitMe = function(){ alert('clicked23!'); //$('#Testing').html('news'); }; 

Here’s the body section:

<body> welcome <form id='SubmitForm' action='/showcontent' method='POST'> <input type='file' name='vsprojFiles' /> <br/> <input type='submit' id='SubmitButton'/> </form>  <div id='Testing'> hi </div>  </body> 

Yet, it is still not working, anything I miss?

  • 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. 2026-05-10T18:30:53+00:00Added an answer on May 10, 2026 at 6:30 pm

    Move the scripts.js script tag down beneath the jQuery script tag and then just move the whole of that inline script block into scripts.js. As jQuery will already have been instantiated by the time scripts.js loads, the Javascript will just execute inline in the same way that it does at the moment.

    Also on a separate note, you need to change

    $('#SubmitForm').click(Submit()); 

    to

    $('#SubmitForm').click(Submit); 

    You don’t want the parentheses because you are not executing the function at this point, merely telling the click event handler that this is the name of the function that you want to execute when the event fires.

    And as another tip, you can replace $(document).ready( with $( ie:

     $(function() {    $('#SubmitForm').click(Submit);  }); 

    Both $ and document.ready can be included anywhere on the page (or in external files) and as long as jQuery.js is in scope, they will fire at the same time (once the DOM has loaded) – you don’t need to worry about it being the last bit of code to fire. This is why you can move the whole thing to scripts.js rather than needing to assign a name to the function and refer to it from the inline script.

    For the record, if you do wish to refer to the function by name, simply define it as a variable:

    var func = function() {   $('#SubmitForm').click(Submit); };  $(func); 

    Like I say though, this is possibly somewhat overkill in your situation, you might as well just move the whole thing to scripts.js (unless of course there’s more to it than you’ve mentioned in your question.

    Edit (to deal with edit to question): Looks like you are dealing with the wrong event handler. You are trying to assign a function to the click event handler for the form, whereas you really want to be assigning it to the handler for the submit button. You should therefore be using the selector ‘#SubmitButton’ ie:

    $('#SubmitButton').click(Submit); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 64k
  • Answers 64k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You're only looking at the top level exception message. Drill… May 11, 2026 at 10:54 am
  • added an answer If you can, I'd recommend having a look at the… May 11, 2026 at 10:54 am
  • added an answer From my copy of n2798: 5.3.4 New 21 Whether the… May 11, 2026 at 10:54 am

Related Questions

I have a simple HTML. I am using the JQuery for AJAX purpose. Now,
I have a simple html page with a div. I am using jQuery to
I have a simple html block like: <span id=replies>8</span> Using jquery I'm trying to
I have a simple HTML (as HTA) application that shows strange behavior on Windows
I have a site that has a simple HTML button in a form. All
I have a very simple html. The red div is inside the blue div
I have a simple form with some plain html input like bellow using ASP.NET
I have developed a simple mechanism for my mvc website to pull in html
Take a very simple case as an example, say I have this URL: http://www.example.com/65167.html
Suppose I have one html page with frames. The left frame is simply a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.