首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >jQuery Freichat冲突

jQuery Freichat冲突
EN

Stack Overflow用户
提问于 2016-09-20 18:26:21
回答 2查看 145关注 0票数 0

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

代码语言:javascript
运行
复制
TypeError: $ is not a function

我尝试用一个匿名函数来封装它,将jQuery作为参数传递,如下所示:

代码语言:javascript
运行
复制
(function($) {
  $(document).ready(function() {
    // my custom code
  });
})(jQuery);

我还使用了jQuery而不是$,得到了以下问题:

代码语言:javascript
运行
复制
jQuery is undefined

对此有什么想法吗?

EN

回答 2

Stack Overflow用户

发布于 2016-09-20 18:30:06

将JQuery库添加到您的文档:

代码语言:javascript
运行
复制
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
票数 0
EN

Stack Overflow用户

发布于 2016-09-20 18:39:31

代码:

代码语言:javascript
运行
复制
    <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">
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39591725

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档