$.ajax html 报not implemented,jquery - My javascript is returning this error: $.ajax is not a functio...

Not sure what's wrong but I'm getting this error from my chrome console:

jquery-3.2.1.slim.min.js:1244 jQuery.Deferred exception: $.ajax is not a function TypeError: $.ajax is not a function

at HTMLDocument. (file:///C:/Users/Adam/Desktop/UseTime/js/example.js:3:7)

at j (file:///C:/Users/Adam/Desktop/UseTime/js/jquery-3.2.1.slim.min.js:1193:55)

at k (file:///C:/Users/Adam/Desktop/UseTime/js/jquery-3.2.1.slim.min.js:1199:45) undefined

r.Deferred.exceptionHook @ jquery-3.2.1.slim.min.js:1244

jquery-3.2.1.slim.min.js:1247 Uncaught TypeError: $.ajax is not a function

at HTMLDocument. (example.js:3)

at j (jquery-3.2.1.slim.min.js:1193)

at k (jquery-3.2.1.slim.min.js:1199)

From this JavaScript:

$(function() { //when the DOM is ready

var times; //declare global variable

$.ajax({ //set up request

beforeSend: function (xhr) { //before requesting data

if (xhr.overrideMimeType) { //if supported

xhr.overrideMimeType("application/json"); // set MIME to prevent errors

}

}

});

//funciton that collect data from the json file

function loadTimetable() { //decalre function

$.getJSON('data/example.json') //try to collect json data

.done(function (data) { //if succesful

times = data; //store in variable

}).fail(function () { //if a problem: show message

$('#event').html('Sorry! we couldnt load your time table at the moment');

});

}

loadTimetable(); //call the function

//CLICK ON TEH EVENT TO LOAD A TIME TABLE

$('#content').on('click', '#event a', function (e) { //user clicks on place

e.preventDefault(); //prevent loading page

var loc = this.id.toUpperCase(); //get value of id attr

var newContent = "";

for (var i = 0; i < times[loc].length; i++) { // loop through sessions

newContent += '

' + times[loc][i].time + '';

newContent += '';

newContent += times[loc][i].title + '

';

}

$('#sessions').html('

  • ' + newContent + '
'); // Display Time

$('#event a.current').removeClass('current'); // update selected link

$(this).addClass('current');

$('#details').text('');

});

//CLICK ON A SESSION TO LEAD THE DESCRIPTION

$('#content').on('click', '#sessions li a', function (e) { //click on session

e.preventDefault(); // prevent loading

var fragment = this.href; //title is in href

fragment = fragment.replace('#', ' #'); //Add Space before #

$('#details').load(fragment); //to load info

$('#sessions a.current').removeClass('current'); //update selected

});

//CLICK ON PRIMARY NAVIGATION

$('nav a').on('click', function (e) { //click on nav

e.preventDefault(); //prevent loading

var url = this.href; //get UR: to load

$('nav a.current').removeClass('current');

$(this).addClass('current');

$('#container').remove(); //remove old

$('#content').load(url + ' #container').hide().fadeIn('slow'); // add new

});

});

I'm not sure if it's an issue with the way I'm initiating .ajax or if my jquery isn't correctly implemented. I think it is. Any Thoughts?

edit: here's the html that goes with the script above

UseTime

HOME

PROFILE

MANAGE TASKS

TIME TABLE

Select a Class from the left
Details
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值