Javascript Error in Ubuntu Uncaught ReferenceError: $ is not defined

主宰稳场 提交于 2019-11-26 22:11:59

问题


I am working with jquery, javascript, php in Ubuntu Platform. In the page i am sending an ajax request through jquery to php file and getting response text. This program was running successfully in windows-(wamp) platform and online. But in Ubuntu i am getting javascript error. The code follows...

    url = "index.php";

    $.get(url,{
            'action': 'Loan',
        },
        function(responseText){     
            alert(responseText);
        },
        "html"
    );

In Ubuntu i am getting this error, "Uncaught ReferenceError: $ is not defined". This error was showing at $.get line. In the script tag i included jquery library file too. I dont know why this is error is coming. Please solve my issue. Thanks in Advance.


回答1:


$ is not defined on JQuery means the JQuery library is not loaded.

It can happen due to many reasons such as,

  1. Path on Windows is not same in Ubuntu.
  2. In windows file names are case insensitive but in Linux its case sensitive.

I suggest you use JQuery from google.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
</script>



回答2:


The error "Uncaught ReferenceError: $ is not defined" means that the JQuery library is not loaded.

You will find all CDN here to include the version of JQuery that you need




回答3:


Instead of using the dollar sign use jQuery.get if it still not working trying verifying your jquery if it exists or not(404). If it exists, open maybe its just an empty file.



来源:https://stackoverflow.com/questions/12998542/javascript-error-in-ubuntu-uncaught-referenceerror-is-not-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!