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

  • Home
  • SEARCH
  • 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 9029115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:10:21+00:00 2026-06-16T07:10:21+00:00

Friends I dont know is it possible or not, But want to do like

  • 0

Friends I dont know is it possible or not, But want to do like mentioned as below, if possible give me the best solution..

index.php

<?php
mysql_connect('localhost', 'root', '') or die (mysql_error());
mysql_select_db('mydb') or die (mysql_error());
?>
<html>
  <head>
    <script type="text/javascript" src="jquery-1.8.2.js"></script>
    <script type="text/javascript">
      $(document).ready(function(){
        $('input[type="button"]').click(function(){
          $.ajax({
            url : 'ajax.php',
            success : function(data){
              alert(data);
            }
          });
        });
      });
    </script>
  </head>
  <body>
    <input type="button" name="button" value="Submit">
    <?php print_r($_REQUEST['data'])?>
  </body>
</html>

ajax.php

<?php
mysql_connect('localhost', 'root', '') or die (mysql_error());
mysql_select_db('mydb') or die (mysql_error());

$query = mysql_query('select * from user');
$count = count($query);
while($row = mysql_fetch_array($query)) {
  $data['name'][] = $row['name'];
}
print json_encode($data);
?>

When I click on submit ajax will call and will get response from in json encoded string as below

{"name":["Nakul Kabra","Bridget Louise","Jayesh Joshi","Jignesh Chaudhary","Jitendra Vihol","Spec Develop","Harshad Sadclown","Andy Estep","Rohan"]}

Now i want to store this ajax response in PHP variable and display it.
How to solve this problem, can anybody help me please..??

Thanks, In advance !!
Your regards.

  • 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-16T07:10:22+00:00Added an answer on June 16, 2026 at 7:10 am

    The short answer is no, it’s not possible. You already had the data in a PHP array before you sent it to the client side. Once the json array arrives, it’s not possible to store it in as a PHP array. That would of course require sending it back to the server.

    In your AJAX success function, you can parse the json and insert it into a form (or any other HTML element). Here’s an example:

    var obj = jQuery.parseJSON(data);
    $.each(obj.name, function(index, value) {
        $('<input>').attr({
            type: 'input',
            name: 'name[]',
            value: value
        }).appendTo('#name_box');
    });
    

    Here’s a sample form:

    <form action="edit_names.php" method="post">
        <div id="name_box"></div>
        <input type="submit" value="Submit" />
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Friends, I like to know using which version of Android SDK we can develop
Friends, I know how to deploy and retrieve a single element in LINQ, but
I don't know if it is possible or not.. I just wanted to work
I want to sell an application developed by me, but this service is not
Friends, Can you please give me significance, difference and uses for Heap and PermGen.
friends. I have a 'make'-like style file needed to be parsed. The grammar is
i want to make something like a friend status if he is online or
UPDATE: I solved this problem exactly the same way friends suggested. But I kind
Possible Duplicate: PHP Curl script to pull data from remote server every 10 minutes
This might be an easy question, but I'd like your help with this. 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.