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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:54:32+00:00 2026-05-28T05:54:32+00:00

i have problem with jquery submit and post. I would like to submit a

  • 0

i have problem with jquery submit and post. I would like to submit a form and post it to my php for a check, and return the php result back to the form. However, I have problem with the returning of data, it basically ignores the result.

This is my html form:

<form id="form" method="post">
    <p id="status">Status:</p>
    <p class="text">
        <label for="name" class="label">Name:</label>
        <input type="text" id="name" name="name" value="" size="30" />
    </p>
    <p class="text">
        <label for="email" class="label">Email:</label>
        <input type="text" id="email" name="email" value="" size="30" />
    </p>
    <p class="submit">
        <input type="submit" name="send_btn" id="send_btn" value="Send" />
    </p>
</form>

This is my javascript to do the submit and post:

$('#form').submit(function(e) {
    e.preventDefault();

        var name = $('#name').val();
        var email = $('#email').val();

        $.post('notify.php', {name: name, email: email}, function(data) {
            $('#status').html(data);
        });

});

This is the php that does the check and return the data:

<?php 
if (isset($_POST['name'], $_POST['email']))
{
    $name = htmlentities($_POST['name']);
    $email = htmlentities($_POST['email']);

    if ($name == "myname")
    {
        $output = 'It matches!';
    }
    else
    {
        $output = 'No matches!";
    }
}
?>

Can please highlight what has gone wrong? Thank you.

  • 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-28T05:54:33+00:00Added an answer on May 28, 2026 at 5:54 am

    You need to echo or die in your php script, so your function can get the results.

    So, change your script to this:

    <?php 
    if (isset($_POST['name'], $_POST['email']))
    {
        $name = htmlentities($_POST['name']);
        $email = htmlentities($_POST['email']);
    
        if ($name == "myname")
        {
            $output = 'It matches!';
        }
        else
        {
            $output = 'No matches!';
        }
    
        echo $output;
    }
    ?>
    

    Notice the third to last line, where I am calling echo $output – whatever you echo will be returned from your ajax call. If you want to get more complex, you should return a JSON object.

    $results = array("result" => "It Matches!", "foo" => "bar");
    echo json_encode($results);
    

    EDIT: You also need to change the " to a ' at the end of your else.

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

Sidebar

Related Questions

I have a form that uses jQuery to submit an ajax post and it
I am using the jQuery disable on submit plug-in but I have a problem.
I have problem while using jquery maskedinput with asp.net textbox. I have a check
I have a problem in integrating PHP and JQuery: My main file is MyFile.html
I need help with what I thought would be a simple form submit problem
i have a problem with jquery form plugin. I try to upload a file
I have form where before i was using simple post with <button name=submit id=register
I have a jquery validation plugin. I don't want my form to submit if
My issue involves jQuery .post and Joomla. I have a template with a form
I have a problem with Jquery function getJSON, the action url does not trigger

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.