dousi8559
2013-09-09 22:29
浏览 42
已采纳

如何在Codeigniter中加载任何特定视图页面之前调用ajax函数

I have a view page below which automatically detects the current user timezone and after detecting timezone , i am sending it to another page for setting the timezone in session for further use.

here is the file(autodetect.php)

<!DOCTYPE html>
<html>
<head> 
    <title>   
    <script type="text/javascript" src="....jquery.js' ?>"></script>  
      <script type="text/javascript"       src='..autodetect/Jsfile/detect1.0.4.min.js'>   
</script> 
 <script>  
 $(function() {   

   <?php if (!isset($_SESSION['tz'])) { ?>
        var timezone = jstz.determine(); 
        $.ajax({
            type: "POST",
            url:"<?php echo base_url('timezone.php'); ?>",
            data: 'timezone='+timezone.name(),
            success: function(data){ 
            }
        }); 
        <?php } ?>   
    }); 
 </script>   
 </head> 
 <body>  
 </body>

,in order to perform this functionality i have to load/read this page(autodetect.php) first,

so my question is "how can i run this page(i.e autodetect.php) before loading any view page or calling any view page via controller?

eg. i have to load the signup page , but before then this i need to read the above php file in order to detect the current timezone of user.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题