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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:01:22+00:00 2026-06-11T07:01:22+00:00

I know some PHP and now I want to combine it using ajax/jquery. Just

  • 0

I know some PHP and now I want to combine it using ajax/jquery. Just for learning purpose im making some scripts. I wanted to make a register form that checks availability etc etc. But before I start to make such a script i’d wanted to do something easier just to check how it works.

My goal was a contact form with ajax and it works. Data gets sended to php validate script. Errors are saved in an array and it returns a list of errors or sends the message.

But I have a few questions:

  1. What if a browser doesnt support javascript. Is there a way to still send the message?
  2. the submit triggers the ajax post function. what is the best way to add jquery validation before it goes to the php file (client side)

    Contact AJAX Form

    <script language="JavaScript" type="text/javascript">
        function ajax_post(){
            // Create our XMLHttpRequest object
            var hr = new XMLHttpRequest();
            // Create some variables we need to send to our PHP file
            var url = "functions/validation.php";
            var name = document.getElementById("name").value;
            var subject = document.getElementById("subject").value;
            var email = document.getElementById("email").value;
            var message = document.getElementById("message").value;
            var vars = "name="+name+"&subject="+subject+"&email="+email+"&message="+message;
            hr.open("POST", url, true);
            // Set content type header information for sending url encoded variables in the request
            hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            // Access the onreadystatechange event for the XMLHttpRequest object
            hr.onreadystatechange = function() {
                if(hr.readyState == 4 && hr.status == 200) {
                    var return_data = hr.responseText;
                    document.getElementById("status").innerHTML = return_data;
                }
            }
            // Send the data to PHP now... and wait for response to update the status div
            hr.send(vars); // Actually execute the request
            document.getElementById("status").innerHTML = "processing...";
    
        }
    </script>
    

    Contact form

    text

        <label>Name
            <span id="nameInfo" class="small">Add your name</span>
        </label>
        <input type="text" name="name" id="name" />
    
        <label>subject
            <span id="subjectInfo" class="small">Add a subject</span>
        </label>
        <input type="text" name="email" id="subject" />
    
        <label>Email
            <span id="emailInfo" class="small">Add a valid email address</span>
        </label>
        <input type="text" name="email" id="email" />
    
        <label>message
            <span id="messageInfo" class="small">Your message min 20 chars</span>
        </label>
        <input type="text" name="message" id="message" />
    
        <button type="submit" onClick="javascript:ajax_post();">Send</button>
        <div class="spacer"></div>
        <div id="status"></div>
    

  • 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-11T07:01:24+00:00Added an answer on June 11, 2026 at 7:01 am

    What if a browser doesnt support javascript. Is there a way to still send the message?

    If you built it properly it the form will submit the data normally if JavaScript isn’t available in the client. Progressive enhancement and should always be how JavaScript is used.

    the submit triggers the ajax post function. what is the best way to add jquery validation before it goes to the php file (client side)

    Use the submit event to capture the form data before submission.

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

Sidebar

Related Questions

I'm just a PHP starter and now I want to learn JQUERY, on my
I've studied about profilers in PHP... Now I want to know: What are some
I'm a total newbie and want to start with php. I know some javascript
I want to make an mmorpg game and i wanted to know some things
I've been making stand-alone Android apps for some time now, but I now want
i am developing an online book store using php and mysql. now i want
Some month ago I created a PDF Creator using FPDF (PHP Class). Now I
I know that some other languages, such as PHP , support a concept of
Can we get variable name('PHPSESSID') defined php.ini through some function in PHP? I know
I know PHP 5 already supports SQLite but for some reason I can't get

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.