2016-09-20 83 views
0

我想给freichat模块集成到我的网站,但我得到这个错误jQuery的Freichat冲突

TypeError: $ is not a function 

我试图用一个匿名函数传递的jQuery作为参数,这样封装它:

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

我也把jQuery,而不是$,得到了以下问题:

jQuery is undefined 

关于这个的任何想法?

+0

显示完整的代码,并添加jquery的文件中正确 –

回答

0

加入jQuery库到您的文档:

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

我已经加入当地的图书馆:

+0

检查网站该文件是否正确调用。只需添加上面的链接然后检查工作如果工作意味着检查您的本地jquery库。 – Dhaarani

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"> 
+1

打开您的浏览器开发控制台(通常是F12),并检查它是否真的在您的服务器上找到了'JS/jquery.js' –