2

我收到错误 jquery is not defined.. 请帮帮我..

 jQuery(function(){
            jQuery('#submitid').click(function(){
                if(jQuery('input[id="EnrollmentServiceAddress1"]').val() != ''){
                    var add2 = jQuery('input[id="EnrollmentServiceAddress2"]').val();
                    if(add2.indexOf('#', 0) && add2 != ''){
                        jQuery('input[id="EnrollmentServiceAddress2"]').val('#'+add2);
                    }
                }
                QadServer.current.submit("#EnrollmentServiceInformationForm");
            });

            jQuery('input[name="residence_type"]').click(function() {
                if(jQuery('input[name="residence_type"]:checked').val() == 'home') {
                    //            jQuery('#add_type').html('Home Number');
                    jQuery('#home_apt').slideUp('slow');
                } else if(jQuery('input[name="residence_type"]:checked').val() == 'apartment') {
                    jQuery('#add_type').html('Apartment Number');
                    jQuery('#home_apt').slideDown('slow');
                }
            });

            jQuery('.qad_suggestion').live('click',function() {
                qad_test();
            });

            jQuery('div[id="change_add"] > span').click(function() {
                jQuery('input[id="EnrollmentServiceAddress1"]').val('');
                jQuery('input[name="residence_type"]:checked').attr('checked', false);
                jQuery('#home_apt').hide();
                jQuery('#change_add').slideUp('slow', function() {
                    jQuery('#validate_add_block').slideDown('slow');
                });
            });

    <?php if($this->Session->check('Enrollment.social_security_number')) { ?>
                //        jQuery('#validate_add_block').hide(); //Old code
                //        jQuery('#change_add').show();
                jQuery('#validate_add_block').show(); //New code
                jQuery('#change_add').hide();
    <?php } ?>
                 init();
             });
4

5 回答 5

3

错误是因为 jquery 文件未正确加载以避免此尝试以下包含 jquery 的代码,如果它未包含在您的页面中...

<script type="text/javascript">
/******** Load jQuery if not present *********/
if (typeof jQuery === "undefined" || jQuery.fn.jquery !== '1.4.2') 
{
    var script_tag = document.createElement('script');
    script_tag.setAttribute("type","text/javascript");
    script_tag.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js")

    document.getElementsByTagName("head")[0].appendChild(script_tag);
    } 
} 


    $(document).ready(function() {
        alert('jQuery Library Loaded');
    });
  </script>
于 2012-04-25T07:09:37.087 回答
2

尝试

 jQuery.noConflict() 

否则尝试替换$ with jQuery.

于 2012-04-25T07:52:32.510 回答
1

将此行放在 jquery 代码的顶部

jQuery.noConflict();
于 2012-04-25T07:08:43.560 回答
0

你包含了 jQuery 吗?

<script type="text/javascript" src="jquery.js"></script>

或者

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

http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery

于 2012-04-25T07:07:58.710 回答
0

在你的视图文件中试试这个
<?php $this->Js->JqueryEngine->jQueryObject = 'jQuery'; ?>

于 2012-04-25T08:00:51.100 回答