CodeIgniter Forums

Full Version: Flashdata with Sweetalert2
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

I have problem when I try to combine flashdata with Sweetalert2,

Controller :
PHP Code:
public function social_settings_pro() 

"disable_social_login" => $disable_social_login,
"twitter_consumer_key" => $twitter_consumer_key,
"twitter_consumer_secret" => $twitter_consumer_secret,
"facebook_app_id" => $facebook_app_id
"facebook_app_secret"=> $facebook_app_secret 
"google_client_id" => $google_client_id,
"google_client_secret" => $google_client_secret,

View :
PHP Code:
<?php if ($this->session->flashdata('globalmsg')): ?>
<script type="text/javascript">
  $(document).ready(function() {
  title: "Done",
  text: "<?php echo $this->session->flashdata('globalmsg'); ?>",
  timer: 1500,
  showConfirmButton: false,
  type: 'success'
<?php endif; ?>

I get error like below,
Uncaught TypeError: Cannot read property 'querySelector' of null
@googlemy, why don't you determine if the flashdata variable exist in the social_settings controller and based on that send it into the view as a variable? This way you can set the variable to a value or false.
@googlemy You are sure that the Sweetalert is working correctly?
For me the Codeigniter Code looks correct.  
Maybe first Test with: 
<script type="text/javascript">
 $(document).ready(function() {
     title: "Done",
     text: "test",
     timer: 1500,
      showConfirmButton: false,
     type: 'success'