document.addEventListener('click', async function (event) {
if (!event.target.matches('button.action, button.action *')) {
return;
}
})
if ( !function_exists ('function_name') ) {
function function_name () { /* ... */ }
}
if ( !class_exists ('class_name') ) {
class class_name { /* ... */ }
}
function request(url, param) {
return new Promise(function (res) {
var url = url;
var csrftoken = getCookie('csrftoken');
data = {'csrfmiddlewaretoken': csrftoken, param: param };
$.ajax({
url: url,
type: "POST",
data: data ,
cache:false,
dataType: "json",
success: function(resp){
res(resp);
}
}) ;
})
}
request(url="/myurl/", param = param).then(function (resp) {
alert(resp.answer);
})
function request(url, param) {
var url = url;
var csrftoken = getCookie('csrftoken');
data = {'csrfmiddlewaretoken': csrftoken, param: param };
return $.ajax({
url: url,
type: "POST",
data: data ,
cache:false,
dataType: "json",
}) ;
}
getSome() {
return this.http.get('/some')
}
second() {
if (this.isEmpty(this.AllMaterial)) {
this.getSome().subscribe( (data: Array<object>)=> {
console.log(data)
this.AllMaterial = data; // не делает запрос
console.log(this.AllMaterial)
}, err => {
console.log(err)
})
}
}