public function ajax() { $json = array('msg' => '', 'flag' => 1); if (is_email($_POST['email'])) { $response = MailChimp::put(array(array($_POST['email'], '', '')), false, true, true); if ($response['error_count'] > 0) { $json['msg'] = self::alert("An error occurred! Sorry, we couldn't sign you on at this point!"); $json['flag'] = 0; } elseif ($response['add_count'] == 0 && $response['update_count'] == 1) { $json['msg'] = self::alert("Seems like we already had you on our list!", "warning"); $json['flag'] = 2; } else { $json['msg'] = self::alert("Thanks Champ for Subscribing! Exciting stuff coming your way!", "info"); } } else { $json['msg'] = self::alert("Invalid email!"); $json['flag'] = 0; } echo json_encode($json); exit; }