我收到错误:
未捕获的TypeError:$ .get不是函数
如果我在加载此函数之前没有导入jquery
,我会理解
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"
integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"
integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"
integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn"
crossorigin="anonymous"></script>
<script>
window.loadCurrentLocation = function(){
$.get("{% url "locations:ajax_get_current_location" %}").done(function (data) {
{# TODO: Osetrit ak neexistuje#}
$('#id_my_current_location').text(data.name);
}
)
};
window.setUserLocation = function(){
var place_id = $('#id_this_place_id').val();
var name = $('#id_this_name').val();
$.get("{% url "locations:ajax_set_current_user_location" %}?place_id=" + place_id + "&name=" + name).done(function (data) {
loadCurrentLocation();
})
}
</script>
你知道问题出在哪里吗?
答案 0 :(得分:3)
您正在加载精简版jQuery而不是完整版。超薄版本没有$.ajax
,$.get
或$.post
助手。
答案 1 :(得分:1)