0
我試圖刪除一個特定的ID從我的SQLite數據庫成功發佈後的時間間隔,但它不工作,雖然它在控制檯打印「成功」。科爾多瓦sqlite刪除不工作
$interval(function(){
var db = $cordovaSQLite.openDB({ name: "allimage.db", location: 'default', bgType: 1 });
var query = "SELECT * FROM allcaseimage";
$cordovaSQLite.execute(db, query).then(function (result) {
var myRowsIds = [];
var len = result.rows.length;
for (var i=0; i<len; i++){
$scope.records_id = result.rows.item(i).records_id;
$scope.caseimage = result.rows.item(i).caseimage;
}
var request = $http({
method: "post",
url: "http://45.55.19.50/mobile/api/savecasepic.php",
data: {
records_id: $scope.records_id,
image : $scope.caseimage
},
headers: { 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8' }
});
request.success(function (data) {
var db = $cordovaSQLite.openDB({ name: "allimage.db", location: 'default', bgType: 1 });
var query = "DELETE FROM allcaseimage where records_id = '"+$scope.records_id+"'";
$cordovaSQLite.execute(db, query, []).then(function(res) {
//success
}, function (err) {
console.error(err);
});
})
}, function (error) {
$scope.showAlert('data error');
})
},20000);
你試過2件東西。 ..一個請求request.then而不是.success ..如果它不起作用..嘗試刪除$間隔,如果你可以 –
嘗試.then()但它沒有工作。我無法刪除$ interval,因此必須刷新函數才能獲取新數據。任何其他選項? –