javascript - 返回值ajax
问题描述
function storeExportFG (dataStore) {
var storeEx = $.ajax({
method: 'get',
url: window.location.origin + '/export-fg-warehouse/store',
cache: false,
data: dataStore,
dataType: 'json'
});
return storeEx;
}
dataStore = {
'id' : table.row(point).data()[1],
'number': table.row(point).data()[5],
};
storeExportFG(dataStore).done(function (data){});
storeExportFG(dataStore).fail(function (err){});
这是我的代码。我遇到的问题是这样做时,我的代码会同时两次添加到数据库中。如何打印出错误值?
解决方案
试试这个方法
dataStore = {
'id' : table.row(point).data()[1],
'number': table.row(point).data()[5]
};
function storeExportFG (dataStore) {
var storeEx = $.ajax({
method: 'get',
url: window.location.origin + '/export-fg-warehouse/store',
cache: false,
data: dataStore,
dataType: 'json'
});
return storeEx;
}
storeExportFG(dataStore).done(function (data){
}).fail(function (err){
});
推荐阅读
- android - 如何序列化字符串资源?
- python - 根据字符串拆分将列表拆分为子列表
- hololens - hololens 模拟器无法连接到共享服务
- angular - 'mat-form-field' 的 Angular 6 错误显示不是已知元素:
- design-patterns - 为什么这个代码在 Kotlin 中是不可能的?
- javascript - pixi.js rotateY 3d 轮播
- dojo - dojox.grid.EnhancedGrid 失去焦点
- jquery - 负边距jquery
- c# - 如何从WPF中的Gridcontrol获取所有行值
- php - 在 Laravel 中重新排序项目