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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:21:54+00:00 2026-05-24T21:21:54+00:00

Very early days playing Javascript, Jquery and Validate. I am using the Submit Button

  • 0

Very early days playing Javascript, Jquery and Validate.

I am using the Submit Button onClick method for form submission.

<input class="submit" type="submit" value="Submit" onClick="submitForm()" />

I am using the submit, in case no data or not every field has been tested.

The logic is working, but the AJAX call does not appear to be working. I have stripped down the PHP to

<?php

touch('phpTouch.txt');
phpinfo();
sleep(30;)
?>

The javascript is

$(document).ready(function () {
    $('#formEnquiry').validate();
});

function submitForm() {
    $('#msgid').append('<h1>Submitting Form (External Routine)</h1>');
    if ($('#formEnquiry').validate().form() ) {
        $("#msgid").append("<h1>(Outside Ready) VALIDATED send to PHP</h1>");
            $.ajax({
            url: "testPHP.php",
            type: "POST",
            data: frmData,
            dataType: "json",
            success: function () {
                alert("SUCCESS:");
            },
            error: function () {
                alert("ERROR: ");
            }
        });
    } else {
        $('#msgid').append('<h1>(Outside Ready) NOT VALIDATED</h1>');
    }
    return false;  // Prevent the default SUBMIT function occurring (is this a fact ??)
};

Can anyone advise as to what I am doing wrong.

Thanks

  • 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-24T21:21:55+00:00Added an answer on May 24, 2026 at 9:21 pm

    Do these things

    Change onClick="submitForm()" on the HTML markup to onclick="submitForm(event)"
    Now change the submitForm function like this.

    function submitForm(evt) {
        $('#msgid').append('<h1>Submitting Form (External Routine)</h1>');
        if ($('#formEnquiry').valid() ) {
            $("#msgid").append("<h1>(Outside Ready) VALIDATED send to PHP</h1>");
                $.ajax({
                url: "testPHP.php",
                type: "POST",
                data: frmData,
                contentType: "application/json;",
                success: function () {
                    alert("SUCCESS:");
                },
                error: function (a, b, c) {
                    alert(a.statusText);
                }
            });
        } else {
            $('#msgid').append('<h1>(Outside Ready) NOT VALIDATED</h1>');
        }
        evt.preventDefault();
    };
    

    Please note these things

    1. Check .valid() to determine form validity
    2. Call .preventDefault() instead of return false; ( Its more jQuery-ish )
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm at the very early stages of a project requiring the broadcasting, using RTP,
Still early days with Mathematica so please forgive what is probably a very obvious
I'm using Hibernate EntityManager and Hibernate Annotations for ORM in a very early stage
I'm very early in the iPhone development learning process. I'm trying to get my
Good afternoon, I am currently in the very early phase of a new project
I'm designing a site. It is in a very early stage, and I have
Very simple question, is there any cloud server enviroments avaliable these days for us
I'm in a very early stage of writing a small music/rhythm game in Java
I'm sure this is something that AJAX gurus learn very early on, but this
I have some code I would like to execute very early in the lifecycle

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.