I have a class similar to this:
class My_Class {
private static $array = null;
private static $another_array = null;
private function __construct() {
self:$another_array = array( 'data' );
}
// This gets executed from jQuery Ajax when user clicks a button
public static function process_ajax() {
self::generate_html();
}
private static function generate_html() {
if ( ! self::$array ) {
self::$array = array( 'some data' );
}
}
// This gets executed when user is trying to save Ajax generated form
public static function save_ajax_form() {
print_r( self::$another_array ); // prints [0] => 'data'
self::validate_data();
}
private static function validate_data() {
// WHY DOES THIS EVALUATE TRUE?
if ( ! is_array( self::$array ) ) {
}
}
}
How can I access My_Class::$array
property from an Ajax call?