Scroll to top

How to get multiple values from ajax in wordpress?

Get multiple values from ajax in wordpress.

Paste this code in main file. 

function single_user_data(){
var ajax = “”;
   var data = {
‘action’ : “get_single_use”,
‘ID’: user_id
var result = $.parseJSON(response)

Paste this code in function.php file.

 function get_single_use(){
  $user_id = $_POST[‘ID’];
  if(function_exists(‘date_default_timezone_set’)) {
// then use the date functions, not the other way around
$date = date(“d/m/Y”);
$date1 =  date(“H:i a”);
global $wpdb;
$table_name = $wpdb->prefix .”customer”;
$result = $wpdb->get_results ( “SELECT * FROM $table_name where ID=’$user_id’ Order by ID desc” );
foreach ( $result as $print )  
  $person = $print->person;
  $phone = $print->phone;
echo json_encode(array($person,$phone));

Leave a Reply

Your email address will not be published. Required fields are marked *