0

i tried to get value of a variable sent from ajax request,but nothing appear in the debugger

Ajax:

$(document).ready(function(){
    var did=$('#did_hidden').val();
    $.ajax({
    type: 'POST',

    url: 'php/classes/Chat.class.php',
    data: { 
        'did': did

    },
    success: function(msg){

    }
});
    })

Chat.class.php

$didx=htmlspecialchars($_POST['did']);
public static function getChats($lastID){
        $lastID = (int)$lastID;

        global $didx;

        $result = DB::query('SELECT * FROM webchat_lines WHERE id > '.$lastID.' and deal_did="$didx" ORDER BY id ASC');

        $chats = array();
        while($chat = $result->fetch_object()){

            // Returning the GMT (UTC) time of the chat creation:

            $chat->time = array(
                'hours'     => gmdate('H',strtotime($chat->ts)),
                'minutes'   => gmdate('i',strtotime($chat->ts))
            );

            $chat->gravatar = Chat::gravatarFromHash($chat->gravatar);

            $chats[] = $chat;
        }

        return array('chats' => $chats);
    }

what the cause of not being able to get $didx value inside class method although i tested it outside class and works well?

Mohamed Amin
  • 997
  • 2
  • 12
  • 29

0 Answers0