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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:03:41+00:00 2026-06-07T03:03:41+00:00

I am trying to pass ajax response value to a php function. ajax.js xmlhttp.onreadystatechange=function(){

  • 0

I am trying to pass ajax response value to a php function.

ajax.js

 xmlhttp.onreadystatechange=function(){
  if (xmlhttp.readyState==4 && xmlhttp.status==200){
    var a = xmlhttp.responseText;
    }
  }

I need a value to be used in PHP function.

test.php

function testFun($a); 

Is this possible??? Thanks for the help!!

  • 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-07T03:03:43+00:00Added an answer on June 7, 2026 at 3:03 am
    Try This:
    /** JAVA SCRIPT **/
    // create a request query
    var queryString = "?send_param=" + a;
    
    // send request query to php file
    xmlhttp.open("GET", "test.php" + queryString, true);
    
    xmlhttp.send(null);
    /** JAVA SCRIPT END **/
    
    /** PHP SCRIPT **/
    [ test.php ]
    
    <?php
    // if $_REQUEST array is empty show error and die;
    if (empty($_REQUEST)) {
    die("Error: No request found");
    } else {
    // split the $_REQUEST array and make array key as php variable
    extract($_REQUEST);
    }
    
    /**
    * Function testFun
    * @param string $a
    */
    function testFun($a)
    {
    // return val
    }
    
    // Call the function
    testFun($send_param);
    ?>
    
    /** PHP SCRIPT END **/
    
    I preferred to use $.ajax function instead to Java Script Ajax, Coz it's handy :) and to good.
    
    
    [1]: http://php.net/manual/en/function.extract.php
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pass this to a PHP script through AJAX: var answers={}; for
I'm trying to pass PHP Function parameters using Javascript (not JQuery) AJAX. Do I
i am trying to pass two values to php file via ajax my code
I'm trying to pass a JavaScript object to a PHP script through jquery.ajax() ,
Trying to pass the variable flickrurl to a PHP page with jQuery/ajax. It works
I'm trying to pass a variable from one function to another, but the var
I'm trying to pass an array to jquery's .ajax() function's data parameter. The first
Possible Duplicate: Passing JavaScript Array To PHP Through JQuery $.ajax I'm trying to pass
I'm trying to pass an array in an ajax request, but apparently it doesn't
I am trying to pass a variable to an ajax request via jquery. I

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.