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.