2016-09-20 12 views
0

私は私のウェブサイトにfreichatモジュールを統合しようとしているが、私は、私は無名関数はこのように、パラメータとしてのjQueryを渡すと、それをカプセル化しようとした、このエラーjQueryのFreichat競合

TypeError: $ is not a function 

を得た:

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

私もjQueryの代わり$を入れて、以下の問題を得た:

jQuery is undefined 

これについて何か考えていますか?

+0

を完全なコードを表示し、適切 –

答えて

0

は、ドキュメントにjQueryライブラリを追加します。

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

をjqueryのファイルを追加し、私はすでにローカルにライブラリを追加します。

+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'を見つけているかどうか確認してください –