我搞错了:
Uncaught:$.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>你知道问题出在哪里吗?
发布于 2017-10-15 12:52:35
您正在加载苗条版本的jQuery,而不是完整的版本。苗条版没有$.ajax、$.get或$.post的助手。
发布于 2017-10-15 12:58:39
在网上找到这个
您使用的是jQuery的瘦版本,它没有AJAX(在您的例子中是$.get()函数)。
使用完整的构建,可以在这里获得http://jquery.com/download/,例如:
https://stackoverflow.com/questions/46755017
复制相似问题