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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:53:36+00:00 2026-06-15T22:53:36+00:00

I have an index.php and a contact.php . index.php uses load() like so: $(#content).load(contact.php);

  • 0

I have an index.php and a contact.php.

index.php uses load() like so: $("#content").load("contact.php"); and everything is great…

My problem is that on contact.php, there is a form, and I can’t seem to get functions to run when the form is submitted.

index.php has jquery loaded. I’ve tried putting this function in and out of a ready tag:

function contact_submit(){
   alert('a');
}

on contact.php:

<form .....
   <input onclick="contact_submit();"  ....

I’ve been experimenting, and put the function on contact.php, but still no luck. I did notice that if I want to use jquery on contact.php I need to include jquery.js on that page (it doesn’t steal it from index).

Does anyone know what i’m doing wrong, or how I can have a function on index.php be used in the loaded contact.php? If you need more of my code please let me know…

EDIT Will I need to put my global function in a .js file and load them on all pages that will be used? I know it sounds like a basic question, but does using load() not re-use Javascript functions on my index page?

  • 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-15T22:53:37+00:00Added an answer on June 15, 2026 at 10:53 pm

    What you need to do is to add an event listener and execute the code after all the DOM Elements have been loaded, provided there are no bugs in your php.

    A few of these may be:

    1. http://api.jquery.com/live/
    2. http://api.jquery.com/on/
    3. http://api.jquery.com/ready/

    The first two apply to individual pages, and the third to DOM.

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

Sidebar

Related Questions

I have a static website with files like index.php, blog.php, contact.php etc How can
I have a index.php file that will include several external files: content/templates/id1/template.php content/templates/id2/template.php content/templates/id3/template.php
Let's say i have an index.php that has html in it that looks like
I have this .htaccess that I've been using to rewrite URLs like these: www.example.com/index.php?page=brand
I have a index.php page that is the main page. All pages are included
i have a question, i have a index.php page that is the intro of
I have a contact form i want to use Ajax for. My contact.php script
I have a website that has an index.php, a few simple .html pages and
I have the following site structure index.php services.php contact.php /admin and the following in
I have a template in joomla without index.php I only have index.html, css file,

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.