jQuery Freichat冲突

时间:2016-09-20 10:26:21

标签: javascript jquery conflict

我试图将freichat模块集成到我的网站,但是我收到了这个错误

TypeError: $ is not a function

我试图用匿名函数封装它,传递jQuery作为参数,如下所示:

(function($) {
  $(document).ready(function() {
    // my custom code
  });
})(jQuery);

我还提出了jQuery而不是$并得到了以下问题:

jQuery is undefined

有关于此的任何想法吗?

2 个答案:

答案 0 :(得分:0)

将JQuery库添加到您的文档中:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

答案 1 :(得分:0)

代码:

    <script src="JS/jquery.js"></script>

    <script language="javascript">
      $(document).ready(function () {
      $("#lawyerrr").select2();
      $("#fromm").select2(); 
      $("#too").select2(); 
      });
    </script>

  <?php
   $ses = null; // Return null if user is not logged in 
   if (!empty($_SESSION['user'])) {
    $loggedUser = $_SESSION['user'];
   }
  if(isset($loggedUser['idd']))
  { 
    if($loggedUser['idd'] != null) // Here null is guest 
   { 
   $ses=$loggedUser['idd']; //LOOK, now userid will be passed to FreiChat 
  } 
} 
//echo $ses;
if(!function_exists("freichatx_get_hash")){
function freichatx_get_hash($ses){

       if(is_file("C:/wamp64/www/freichat/hardcode.php")){

               require "C:/wamp64/www/freichat/hardcode.php";

               $temp_id =  $ses . $uid;

               return md5($temp_id);

       }
       else
       {
               echo "<script>alert('module freichatx says: hardcode.php file not
found!');</script>";
       }

       return 0;
}
}

 ?>
    <script type="text/javascript" language="javascipt" src="http://localhost/freichat/client/main.php?id=<?php echo $ses;?>&xhash=<?php echo freichatx_get_hash($ses); ?>"></script>
    <link rel="stylesheet" href="http://localhost/freichat/client/jquery/freichat_themes/freichatcss.php" type="text/css">