PHP_SMART_HOME_V3/app/templates/js/post.js

73 lines
2.1 KiB
JavaScript
Raw Normal View History

2019-08-24 11:07:07 +00:00
function ajaxPostSimple(path, params, reload = false) {
navigator.vibrate([200]);
$.ajax({
url: path,
type: 'POST',
data: params,
success: function(msg){
console.log(msg);
if (reload){
location.reload();
}
},
error: function (request, status, error) {
console.log('0');
}
});
return false;
}
2019-08-23 11:39:42 +00:00
function ajaxPost(path, params, self, reload = false) {
navigator.vibrate([200]);
$.ajax({
url: path,
type: 'POST',
data: params,
success: function(msg){
if (msg != '' && msg != 1){
$(self).find('.content').addClass( "loader" );
$(self).find('.row').hide();
waitForExecution(params, self, msg);
} else {
}
console.log(msg);
if (reload){
location.reload();
2019-08-23 11:39:42 +00:00
}
},
error: function (request, status, error) {
console.log('0');
}
});
return false;
}
function waitForExecution(params, elements, msg_state){
console.log('Waiting FOR Executed');
var interval = setInterval(
function(){
$.ajax({
url: 'ajax',
type: 'POST',
data: {
2019-10-09 17:26:29 +00:00
action:'executed',
2019-08-23 11:39:42 +00:00
subDevice_id : params['subDevice_id']
},
success: function(msg){
if (msg == 1){
$(elements).find('.text-right').text(msg_state);
$(elements).find('.content').removeClass( "loader" );
$(elements).find('.row').show();
console.log('Executed');
clearInterval(interval);
}
console.log('Waiting FOR Executed');
console.log(msg);
},
error: function (request, status, error) {
console.log('0');
}
});
}, 1000);
}