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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:37:03+00:00 2026-06-16T00:37:03+00:00

<form action= method=post> <input type=text name=name /> <input type=text name=email /> <input type=text name=qty

  • 0
<form action="" method="post">
<input type="text" name="name" />
<input type="text" name="email" />
<input type="text" name=qty" />
<textarea name="message"></textarea>
<input type="submit" class="submit" onclick="formSubmit(event)" />
</form>

now, i using ajax to submit the information to http://example.com/test.php. how to access the inputname,email,phone,message value in test.php, i konw, if don’t use ajax, i can used $_POST[’email’]..to access the passed value.

if i also want to use $_POST[’email’].how do i do? after instructed by someone, i did the following, but in the test.php. it doesn’t access the vaule, what’s wrong with it?

var dataString =  '&name=' + jQuery('input[name=name]').val() +                 
                         '&email=' + jQuery('input[name=email]').val() +
                         '&qty=' + jQuery('input[name=qty]').val() +
                         '&message=' + jQuery('textarea[name=message]').val() +
       jQuery.ajax({
            type: "POST",
            url: "http://www.example.com/test.php",
            data: dataString,

then in test.php i using. $_POST[’email’],$_POST[‘qty’]…it doesn’t work.

the last code: i added class=”ajax-submit” to the

jQuery('form.ajax-submit').submit(function(e) {
    var $this = jQuery(this);
    e.preventDefault();

    if ($this.find('input[name="email"]').val() == '' || $this.find('input[name="qty"]').val() == ''|| $this.find('input[name="message"]').val()=='')) {
    alert("please fill out the required fields");
    return false;
}

    jQuery.ajax({
         type: "POST",
         url: "http://example.com/test.php",
         data: $this.serialize(),
        success: function(response) {
            alert(response);
        },
        error: function() {
                alert('There was an error submitting the form');
            } 
    })
});
  • 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-16T00:37:04+00:00Added an answer on June 16, 2026 at 12:37 am

    Don’t construct the query string by hand. What you have now doesn’t escape the values, which makes it easy to break.

    Instead, just let jQuery serialize the form for you:

    $('form.ajax-submit').submit(function(e) {
        var $this = $(this);
        e.preventDefault();
    
        $.ajax({
            url: $this.attr('action') || window.location,
            type: $this.attr('method') || 'post',
            data: $this.serialize(),
            success: function(response) {
                alert(response);
            }
        })
    });
    

    This code makes all forms with the class ajax-submit submit via AJAX.

    To fix what you have now, just change your data key’s value:

    var $form = $('#your_form');
    
    if ($form.find('input[name="email"]').val() == '' || $form.find('input[name="name"]').val() == '') {
        return false;
    }
    
    jQuery.ajax({
        type: "POST",
        url: "http://www.example.com/test.php",
        data: $form.serialize(),
        ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HTML <form id=contact_form action=# name= method=POST> <label for=name>NAME</label> <input type=text name=name id=name class=contact_form_input />
<form action = settings.php method = post> Student ID*: <input type = text name
<form id='new_key' action='/foo/bar' method='post'> <input type=text id=u> <input type=submit value=submit> </form> I can bind
I have a simple form like this: <form name=serachForm method=post action=/home/search> <input type=text name=searchText
form html: <form action='/register/' method = 'post'>{% csrf_token %} ... <label>Avatar: </label><input type='file' name='avatar'
I have an HTML form: <form action='process.php' method='post'> <input type='checkbox' name='check_box_1' /> Check me!<br>
I have a form. With the following: HTML: <form name=feedback_form method=post action= class=feedback_form> <input
I have this HTML: <form action='uploadhandle.php' method='POST' enctype=multipart/form-data> <input type='file' class='fileinput' id='photo1' name='photo1'> <input
I have a form. With the following: HTML: <form name=feedback_form method=post enctype=multipart/form-data action= class=feedback_form>
I have contact form structure. With the following: HTML: <form name=feedback_form method=post action= class=feedback_form>

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.