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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:34:40+00:00 2026-05-26T15:34:40+00:00

I found this code and am trying to adjust it to the way I

  • 0

I found this code and am trying to adjust it to the way I need. I really have no knowledge of javascript/jquery so I would like some assistance.

Code:

$(document).ready(function() {

    //if submit button is clicked
    $('#submit').click(function () {        

        //Get the data from all the fields
        var name = $('input[name=name]');
        var email = $('input[name=email]');
        var website = $('input[name=website]');
        var comment = $('textarea[name=comment]');

        //Simple validation to make sure user entered something
        //If error found, add hightlight class to the text field
        if (name.val()=='') {
            name.addClass('hightlight');
            return false;
        } else name.removeClass('hightlight');

        if (email.val()=='') {
            email.addClass('hightlight');
            return false;
        } else email.removeClass('hightlight');

        if (comment.val()=='') {
            comment.addClass('hightlight');
            return false;
        } else comment.removeClass('hightlight');

        //organize the data properly
        var data = 'name=' + name.val() + '&email=' + email.val() + '&website=' + 
        website.val() + '&comment='  + encodeURIComponent(comment.val());

        //show the loading sign
        $('.loading').show();
        //start the ajax
        $.ajax({
            //this is the php file that processes the data
            url: "process.php", 

            //GET method is used
            type: "POST",

            //pass the data         
            data: data,     

            //Do not cache the page
            cache: false,

            //success
            success: function (html) {              
                            $('.loading').hide();
                //DISPLAY RECEIVED CONTENT FROM "process.php" IN DIV NAMED "done"       

            }       
        });

        //cancel the submit button default behaviours
        return false;
    }); 
});

This is the previous code that I removed from the success part:

success: function (html) {              
                //if process.php returned 1/true (send mail success)
                if (html==1) {                  
                    //hide the form
                    $('.form').fadeOut('slow');                 

                    //show the success message
                    $('.done').fadeIn('slow');

                //if process.php returned 0/false (send mail failed)
                } else alert('Sorry, unexpected error. Please try again later.');               
            }

Upon getting the info, process.php would respond “1” and the form would fade out and the text in div “done” would fade in.

process.php is basically: (just sending back the data it received for testing purposes)

$name = ($_GET['name']) ? $_GET['name'] : $_POST['name'];
$email = ($_GET['email']) ?$_GET['email'] : $_POST['email'];
$website = ($_GET['website']) ?$_GET['website'] : $_POST['website'];
$comment = ($_GET['comment']) ?$_GET['comment'] : $_POST['comment'];

echo "$name<br>$email";

Like I said I know nothing of javascript, jquery, so any help would be appreciated.

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-26T15:34:41+00:00Added an answer on May 26, 2026 at 3:34 pm

    if you are receiving html you can do

    success: function (html) {  
     $('.loading').hide(); 
    $(".done").html(html).fadeIn('slow');
    }
    

    i think you need to echo something like

    echo $name."<br/>".$email;
    

    to reset the form assuming myform is the id of your form

    $(':input','#myform')
     .not(':button, :submit, :hidden')
     .val('')
     .removeAttr('checked')
     .removeAttr('selected');
    

    ref: Resetting a multi-stage form with jQuery

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

Sidebar

Related Questions

I'm trying to parse a html doc using some code I found from this
I'm trying to learn the Enterprise Library. I found this useful code sample to
I found this line of code and I'm trying to comprehend what it's doing.
While trying to answer this question I found that the code int* p =
I'm trying this code (found in an answer here on SO) in a category
i found this code online and im trying to compile it, but gcc keeps
I found this code here while trying to understand what an actionstack does and
I am trying to add a TrackBar in my ToolStrip. I have found this
I found this code below in a script, I am trying to figure out
I found this code online. I was trying to get it to write the

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.