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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:05:13+00:00 2026-06-04T12:05:13+00:00

this ajax function gets a textbox value and sends it to response.php : (this

  • 0

this ajax function gets a textbox value and sends it to "response.php": (this is main function of ajax.js)

function ajaxFunction() {
  var getdate = new Date(); 

  if(xmlhttp) {

    var txtname = document.getElementById("txtname");

    xmlhttp.open("POST","response.php",true); 
    xmlhttp.onreadystatechange  = handleServerResponse;
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send("txtname=" + txtname.value); 
  }
}

i am trying to add a radio button set to my form, so i changed this to:

function ajaxFunction() {

  var getdate = new Date();  
  if(xmlhttp) {

    var txtname = document.getElementById("txtname");
    var radio = document.getElementById("radio2"); //ADDED

    xmlhttp.open("POST","response.php",true); 
    xmlhttp.onreadystatechange  = handleServerResponse;
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send("txtname=" + txtname.value); 
    xmlhttp.send("radio=" + radio.value); //ADDED

  }
}

and in response.php :

<?php

if (isset($_POST['txtname'])){
 $radio =  $_POST['radio'];

       //process...

}

?>

input text still works but radio buttons not.

  • 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-04T12:05:14+00:00Added an answer on June 4, 2026 at 12:05 pm

    It may seem that your variable name is not “radio2” but “radio”.

    <?php 
    if (isset($_POST['txtname'])){
       // $radio =  $_POST['radio2']; // <-- here
       $radio =  $_POST['radio']; // fixed
    
         //process...
    }
    ?>
    

    Because you post the data by the name of “radio”.

    xmlhttp.send("radio=" + radio.value); //ADDED
    

    —–ADDED MY ANSWER BELOW —-

    And please try …

    xmlhttp.send("txtname=" + txtname.value + "&radio="+ radio.value); 
    

    or

    xmlhttp.send("txtname=" + txtname.value + "&radio2="+ radio.value); 
    

    Because you can not use xmlhttp.send() twice.

    I hope this helps you.

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

Sidebar

Related Questions

i have an ajax function which gets called and returns json data. this function
I have this: $.ajax({ url: blah.php?something, dataType: json .... success: function(x){ for(i in x.artists)
I do this ajax request: var response = $.ajax({ url: 'product/add', data: $(#formAddNewRow).serialize(), type:
I'm having hard time with this simple ajax call function sendreq() { $.ajax({ dataType:
How to pass multiple checkboxes using jQuery ajax post this is the ajax function
I execute an ajax function that takes 3 seconds + so in this time
It seems that i cannot access $(this) inside jquery ajax success function. please see
A few days ago I asked this question about jquery ajax function invoking action
I am using the jQuery $.ajax() function. I have put this into a parent
Having issues referencing $(this) from within a the nested ajax 'success' function... I know

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.