简体   繁体   English

未捕获的TypeError:undefined不是函数

[英]Uncaught TypeError: undefined is not a function

I am getting Uncaught TypeError: undefined is not a function error and its count is increasing tremendously even above 3000 times. 我得到了Uncaught TypeError: undefined is not a function错误,它的数量甚至超过了3000倍。 as shown in the following images. 如下图所示。

Jquery错误

jquery错误未定义

I also tri list of other js files that I am using on the website in the same order I have mentioned below. 我还列出了我在网站上使用的其他js文件,其顺序与我在下面提到的顺序相同。

1.3.2/jquery.min.js
1.7.2/jquery-ui.min.js
ui.stars.min.js
jquery.qtip-1.0.0-rc3.min.js
jquery.fancybox-1.2.6.pack.js

I tried changing the version of jquery.min.js to 1.9.1. 我尝试将jquery.min.js的版本jquery.min.js为1.9.1。 but still i am getting the error. 但我仍然得到错误。 and I am also using 我也在用

<script src="cufon/cufon-yui.js" type="text/javascript"></script>
<script type="text/javascript">
    //statement
</script>

and

here is my custom javascript which is also included on to the website 这是我的自定义JavaScript,也包含在网站上

$(document).ready(function () {
  /* Executed on DOM load */
  $("#slogan-addbutton").fancybox({
    'zoomSpeedIn': 600,
    'zoomSpeedOut': 500,
    'easingIn': 'easeOutBack',
    'easingOut': 'easeInBack',
    'hideOnContentClick': false,
    'padding': 15
  });
/* Listening for keyup events on fields of the "Add a note" form: */
    $('.pr-body,.pr-author').live('keyup',function(e){
        if(!this.preview)
            this.preview=$('#fancy_ajax .note');

        /* Setting the text of the preview to the contents of the input field, and stripping all the HTML tags: */
        this.preview.find($(this).attr('class').replace('pr-','.')).html($(this).val().replace(/<[^>]+>/ig,''));
    });

    /* Changing the color of the preview note: */
    $('.color').live('click',function(){
        $('#fancy_ajax .note').removeClass('yellow green blue').addClass($(this).attr('class').replace('color',''));
    });

    /* The submit button: */
    $('#note-submit').live('click',function(e){

        if($('.pr-body').val().length<4)
        {
            alert("The note text is too short!")
            return false;
        }

        if($('.pr-author').val().length<1)
        {
            alert("You haven't entered your name!")
            return false;
        }

        $(this).replaceWith('<img src="img/ajax_load.gif" style="margin:30px auto;display:block" />');

        var data = {
            'zindex'    : ++zIndex,
            'body'      : $('.pr-body').val(),
            'author'        : $('.pr-author').val(),
            'color'     : $.trim($('#fancy_ajax .note').attr('class').replace('note',''))
        };


        /* Sending an AJAX POST request: */
        $.post('post.php',data,function(msg){

            if(parseInt(msg))
            {
                /* msg contains the ID of the note, assigned by MySQL's auto increment: */

                var tmp = $('#fancy_ajax .note').clone();

                tmp.find('span.data').text(msg).end().css({'z-index':zIndex,top:0,left:0});
                tmp.appendTo($('#main'));

                make_draggable(tmp)
            }

            $("#addButton").fancybox.close();
        });

        e.preventDefault();
    })

    $('.note-form').live('submit',function(e){e.preventDefault();});


  $(".star-rating").stars();
  /* Converts all the radio groups into star ratings */

  $("#quotes-hide").mousemove(function (e) {
    /* The scrollable quote container */

    if (!this.hideDiv) {
      /* These variables are initialised only the firts time the function is run: */

      this.hideDiv = $(this);
      this.scrollDiv = $('#quotes-slide');

      this.pos = this.hideDiv.offset();
      this.pos.top += 20;
      /* Adding a 20px offset, so that the scrolling begins 20px from the top */


      this.slideHeight = this.scrollDiv.height();

      this.height = this.hideDiv.height();
      this.height -= 20;
      /* Adding a bottom offset */

      this.totScroll = this.slideHeight - this.height;
    }

    this.scrollDiv.css({
      /* Remember that this.scrollDiv is a jQuery object, as initilised above */

      marginTop: '-' + this.totScroll * (Math.max(e.pageY - this.pos.top, 0) / this.height) + 'px'
      /* Assigning a negative top margin according to the position of the mouse cursor, passed
               with e.pageY; It is relative to the page, so we substract the position of the scroll container */
    });

  });


  $('.thumb').click(function (e) {
    /* Executed once a quote from the list on the right is clicked */

    var obj = quotes[parseInt(e.target.id.replace('q-', '')) - 1];
    /* The e.target.id of the quote corresponds to its position in the quotes array */

    $('#slogan-quote-content').fadeOut('fast', function () {
      /* This is a callback function, run once the quote contaier on the left has faded out */

      if (!obj) return false;

      /* Replacing the contents of the quote text and author */

      $(this).find('h1').html(obj.txt);
      $(this).find('span').html(obj.author);

      /* Changing the background color */

      if (obj.bgc) $('body').stop().animate({
        backgroundColor: obj.bgc
      }, 'slow');

      /* Generating the radio boxes for the tool-tip star rating */

      var tmpstr = '';
      for (var z = 0; z < 5; z++) {
        tmpstr += '<input type="radio" name="voteQ" value="' + (z + 1) + '" ';

        if (z + 1 == obj.rating) tmpstr += 'checked=checked ';
        if (parseInt(obj.voted)) tmpstr += 'disabled="disabled" ';

        tmpstr += '/>';
      }

      tmpstr = '<div id="voteRating">' + tmpstr + '</div>';

      /* Updating the content of the tool-tip and converting it to a star rating */
      $('#slogan-box').qtip("api").updateContent(tmpstr);

      $('#voteRating').stars({
        cancelShow: false,
        oneVoteOnly: true,
        callback: function (ui, type, value) {
          vote(obj, value);
        }
      });

      /* Regenerating the cufon text replacement for the new quote text on the left */
      Cufon.refresh();

      /* Show the new quote with a fade-in effect */
      $(this).fadeIn('fast');
    });
  });

  /* Creating and configuring the tool-tip with the help of the qtip plugin */
  $('#slogan-box').qtip({
    content: {
      text: 'This is an active list element',
      title: {
        text: 'Vote for this quote'
      },
      prerender: true
    },

    show: 'mouseover',
    hide: {
      delay: 2000,
      fixed: true,
      when: 'mouseout'
    },
    position: {
      corner: {
        target: 'rightMiddle',
        tooltip: 'leftMiddle'
      },
      adjust: {
        y: 20
      }
    },
    style: {
      border: {
        width: 2,
        radius: 6
      },
      name: 'light',
      tip: 'leftMiddle'
    }
  });

  /* After the page has loaded, click the first quote on the right */
  setTimeout(function () {
    $('#q-1').click();
  }, 250);
});

/* The global array holding all the data about the quotes. Filled in on page load. */
var quotes = new Array();

function fillData(obj) {
  quotes.push(obj);
}

function vote(ob, value) {
  /* Sending the votes to vote.php */
  $.post('vote.php', {
    qid: ob.id,
    vote: value
  }, function (data) {

    if (data == "1") {
      /* If the vote was saved successfully, update the quote data.. */
      ob.voted = 1;
      ob.votes = ob.votes + 1;
      ob.vsum = ob.vsum + parseInt(value);
      ob.rating = Math.round(ob.vsum / ob.votes);

      /* ..and update the star rating */
      $('#rating-' + ob.id).stars("select", ob.rating);
      quotes[ob.id - 1] = ob;
    }
  });
}

This may be due the other jQuery file included. 这可能是由于包含了其他jQuery文件。

1.7.2/jquery-ui.min.js
ui.stars.min.js
jquery.qtip-1.0.0-rc3.min.js
jquery.fancybox-1.2.6.pack.js

These files may have not been updated to be compatible with jquery.min.js(1.9.1). 这些文件可能尚未更新为与jquery.min.js(1.9.1)兼容。 Some of these files may be using a function which has been deprecated in the 1.9.1 version of the jquery. 其中一些文件可能正在使用在jquery的1.9.1版本中已弃用的函数。

So try to find the compatible versions of these files and replace with new versions. 因此,请尝试查找这些文件的兼容版本,并替换为新版本。 And change the deprecated methods with the new methods available in the 1.9.1. 并使用1.9.1中提供的新方法更改已弃用的方法。

For example: 例如:

.live(events, function) //was available in older versions and deprecated in 1.9.1 jquery

this has been mapped to: 这已被映射到:

.on(eventType, selector, function)  //in 1.9.1 jquery

You can also try to add this to the header: 您还可以尝试将其添加到标题中:

<script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script>

This will make some uncompatible things to work with the new jQuery version. 这将使一些不兼容的东西与新的jQuery版本一起使用。

It's not the best solution, but if you are in hurry it could help a lot. 这不是最好的解决方案,但如果你赶时间,它可以提供很多帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM