我有這段代碼來獲取兩部分數據,這兩個Ajax請求從php類中獲取數據。如何將信息從一個Ajax請求放入另一個
{
xtype: 'button',
formBind: true,
id: 'saveLicenceBtn',
text: 'Save',
listeners: {
click: function (c) {
//first ajax request
var d = Ext.Ajax.request({
url: 'system/index.php',
params: {
class: 'generatemultiple',
method: 'getSession'
},
success: function (response) {
var object = Ext.decode(response.responseText, true);
console.log(object);
},
failure: function (response) {
var object = Ext.decode(response.responseText, true);
console.log(object);
}
});
//second ajax request
Ext.Ajax.request({
url: 'system/index.php',
method: 'POST',
params: {
class: 'generatemultiple',
method: 'add',
data: Ext.encode({
count: Ext.getCmp('count').getValue(),
start_date: Ext.getCmp('startdateTextField').getValue(),
end_date: Ext.getCmp('enddateTextField').getValue(),
duration: Ext.getCmp('durationTextField').getValue(),
expiry_date: Ext.getCmp('expirydateTextField').getValue(),
product_id: Ext.getCmp('productidTextField').getValue(),
company_id: Ext.getCmp('companyidtf').getValue(),
token: d
})
},
success: function (response) {
Ext.MessageBox.alert('Status', 'Success');
Ext.getStore('LicenseStore').reload();
Ext.getStore('LicenseAllStore').reload();
Ext.getStore('LicenseFeaturesStore').reload();
Ext.getStore('HardwareStore').reload();
Ext.getStore('DropdownLicenseStore').reload();
Ext.getStore('GridHardwareStore').reload();
Ext.getStore('HardwareAllStore').reload();
Ext.getCmp('addLicenseWindow').close();
},
failure: function (response) {
Ext.MessageBox.alert('Status', 'Failure');
Ext.getCmp('addLicenseWindow').close();
}
});
}
}
}
第一AJAX請求從網頁獲取會話變量,並且所述第二AJAX請求發送該令牌與AJAX請求。我需要知道的是,如何在不出現此錯誤的情況下執行此處顯示的內容。
Uncaught RangeError: Maximum call stack size exceeded
我知道什麼是錯誤的手段和我知道爲什麼它發生的歷史原因,但我不能找到一個解決方案。它保持發生,因爲我有兩個函數互相調用,所以它在Web控制檯中的錯誤。
我或者試圖爲這個
ONCLICK
click: function (c) {
Ext.Ajax.request({
url: 'system/index.php',
method: 'POST',
params: {
class: 'generatemultiple',
method: 'add',
data: Ext.encode({
count: Ext.getCmp('count').getValue(),
start_date: Ext.getCmp('startdateTextField').getValue(),
end_date: Ext.getCmp('enddateTextField').getValue(),
duration: Ext.getCmp('durationTextField').getValue(),
expiry_date: Ext.getCmp('expirydateTextField').getValue(),
product_id: Ext.getCmp('productidTextField').getValue(),
company_id: Ext.getCmp('companyidtf').getValue(),
token: '<?php echo $_SESSION["user_id"] ?>'
})
},
success: function (response) {
Ext.MessageBox.alert('Status', 'Success');
Ext.getStore('LicenseStore').reload();
Ext.getStore('LicenseAllStore').reload();
Ext.getStore('LicenseFeaturesStore').reload();
Ext.getStore('HardwareStore').reload();
Ext.getStore('DropdownLicenseStore').reload();
Ext.getStore('GridHardwareStore').reload();
Ext.getStore('HardwareAllStore').reload();
Ext.getCmp('addLicenseWindow').close();
},
failure: function (response) {
Ext.MessageBox.alert('Status', 'Failure');
Ext.getCmp('addLicenseWindow').close();
}
});
}
原諒縮進。我試圖做的最終目標是通過這個ajax請求發送來自php的session變量
您可以將第二個請求嵌套到第一個請求的'success'函數中。 –
我做到了,但仍然給我上面指出的錯誤 –
請不要粘貼整個代碼的問題。 http://stackoverflow.com/help/mcve – blue112