$ not defined in JavaScript

核能气质少年 提交于 2019-12-02 09:11:03

问题


Firebug is reporting that

$ is not defined [Break On This Error] $(function(){

I have a simple index.php page that does a php include to include the contents I need.

The contents are as follows:

<script type="text/javascript">
$(function(){
    $("#ipad").submit(function() {
        $.post("ipadcheck.php", $("#ipad").serialize(),
        function(data) {
            if(data.error == 'TRUE') {  
                    $("#results_ajax").html("<div class='AppleRedBold'>Sorry There were     Errors: " + data.error_message + "</div>");
            } else {
                $("#results_ajax").html("<div class='AppleRedBold'>" + data.display + "    </div>");
            }
        }, "json");

        return false;

    });
});
</script>

<div class="paragraph_style" id="results_ajax"></div>

    <div class="paragraph_style">
        <form id="ipad" name="ipad">
                <label class="paragraph_style" for="txtZip">Zip Code:     </label>
                <input class="searchBox Black" id="txtZip" name="txtZip" type="text" />
                <br /><br />
                <input type="submit" value="Submit">
        </form>
    </div>                  
</div>

I do this in other places and I am fine. I don't understand the error.....


回答1:


Did you include the jQuery library?




回答2:


Add this before your script tag. It uses google's CDN.

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>



回答3:


Are you including jQuery at the top of your script?



来源:https://stackoverflow.com/questions/5421910/not-defined-in-javascript

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