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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:06:13+00:00 2026-05-26T10:06:13+00:00

I have a simple AJAX request which sends data to a PHP and the

  • 0

I have a simple AJAX request which sends data to a PHP and the PHP sends some sucess data back to the AJAX as usual. For example

var firstvalue = xxx;
var secondvalue = xxx2;

AJAX

$.post("some.php",{value1 : firstvalue, value2 : secondvalue}, function(data){
    if(data) {
        alert(data);
    } else {
        alert("An error occurred.");
    }
});

PHP (some.php)

$id = S_GET['someid'];
$impdata = $_GET['somegettabledata']
$value1 = $_POST['value1'];
$value2 = $_POST['value2'];

if (value1 === value2) {
    /* 
    This is my problem I want to echo id and impdata 
    but I don't know how to pass both of them
    */
    echo "...";
} else {
    echo "Error.";
}

So how can I have both the id and impdata in that data sent back from PHP? Sorry if this comes across as stupid.

Many 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-26T10:06:13+00:00Added an answer on May 26, 2026 at 10:06 am

    In PHP:

    echo json_encode( array(
        'id' => $id,
        'impdata' => $impdata
    ));
    

    In javascript you will need to parse the json string:

    function(data){
        var myData = JSON.parse(data);
        alert(myData.id); //other notation: myData['id']
        alert(myData.impdata); //other notation: myData['impdata']
    }
    

    JSON parser can be found at the bottom of the following page: http://www.json.org/js.html

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

Sidebar

Related Questions

I have a simple example of PHP sessions and AJAX, which works when holding
I have a simple jquery/ajax request to the server which returns the structure and
I have an AJAX request (using JQuery) that calls a PHP script which does
I have a button, Add to Cart which sends an ajax request when clicked.
i have a simple Jquery code which is for sending $.ajax request and passing
I have seen simple example Ajax source codes in many online tutorials. What I
I have written a simple jQuery.ajax function which loads a user control from the
I had a realtivley simple ajax application, which I have broken up to be
I have an ajax form in asp.net mvc which is as simple as this:
I've got a simple $.ajax request that I am trying to fetch some HTML

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.