JQuery issue “TypeError: $.getJSON is not a function”

后端 未结 3 1851
生来不讨喜
生来不讨喜 2020-12-03 06:36

I\'ve got this piece of code:

$(document).ready(function () {
    $.getJSON(\'http://localhost:5000/\', function (response) {
        console.log(response);
         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 07:14

    Thus happens commonly when migrating codebases from jQuery v1.x+ to v3.0+ as jQuery updated/deprecated/discontinued some of it's API.

    I recommend using jQuery Migrate which will address this, along with other issues:

    Get it here via CDN:

    https://cdnjs.com/libraries/jquery-migrate

    If using Gulp/Grunt, you can import into your project using

    npm install --save jquery jquery-migrate

    Github Repository - https://github.com/jquery/jquery-migrate

    Read more about jQuery v3.0+.. http://blog.jquery.com/2016/06/09/jquery-3-0-final-released/

提交回复
热议问题