How to make an ajax call in API using Framework7
4 answers
You can include jQuery or use the default Dom7 library, it has the same Ajax methods:
var $$ = window.Dom7;
//do get request
$$.get('path-to-file.php', {id: 3}, function (data) {
console.log(data);
});
//do post request
$$.post('path-to-file.php', {id: 3}, function (data) {
console.log(data);
});
//get JSON request
$$.getJSON('path-to-file.js', function (json) {
console.log(json);
});
+7
source to share
This is the same as a normal ajax call. use $$ instead of $ as $ DOM is assigned by $$.
$$.ajax({
url:url2,
data:{'json_order':jsonOrder},
type:'POST',
beforeSend:function(){
myApp.showPreloader('Please Wait');
},
success:function(data)
{
myApp.hidePreloader();
console.log(data);
if(data =='success')
{
alert('success');
}
else
{
alert('no data');
}
}
});
+1
source to share
Framework7 uses syntax similar to jQuery ajax. The POST call can be as follows:
$$.post('auth.php', {username:'foo', password: 'bar'}, function (data) {
$$('.login').html(data);
console.log('Load was performed');
});
See the DOM section for more examples of the official documentation for Framework7.
0
source to share