Can you please advise, where to place an ajax request, in order for it to be called only once - when the app is first opened?
Tried to hook it to “Init” (see sample below) but receive “$$.ajax is not a function”.
var app = new Framework7({
on: {
init: function () {
$$.ajax ({
//AJAX call
});
}
}
});.
I also tried to put it this way, but it also doesn’t work.
$$(document).on(‘page:init’, ‘.page[data-name=“home”]’, function (e, page) {
//AJAX call
})
I do understand that app.request is the correct way of calling it, however, app.request upon app:init event returns “app is undefined”, which obviously means that app is not yet defined at that time, when init event is fired.
So I tried with $$.ajax, instead.
Can you please point me to the right direction to resolve this?
One additional question, if I may ask - is it possible to define a global APP variable within the app:init event?
Tried both - this.data.myvariable = ‘foo’ and Framework7.data.myvariable = ‘foo’, but both return this global variable as undefined.
I don’t know if that’s the best approach, but got this working by assining the instance context to a variable before the this.request call, so I am able to access this after the success.
Прошу прощения, а есть ли минимальный рабочий пример, как получить через AJAX JSON результаты на главное окно? Чтобы уже с этого начать строить свое первое приложение.
P.S. Кто бы мог помочь за небольшое вознаграждение?