Forum /
Sencha Touch 2.x Forums /
Sencha Touch 2.x: Discussion /
Problem in using JsonP request
Problem in using JsonP request
hi all,
I am using following code on tap of a button in my app to add some item to my cart on the server.
Ext.data.JsonP.request({
url : localStorage.getItem('serverPath') + 'addToCart.php',
//callbackKey: 'callback',
params: {
strEmail: sessionStorage.getItem('loginUserId'),
customerId: sessionStorage.getItem('customerId'),
productSKU: sizeRecord[0].get('sizeSkuModifier') + productInfoStore.get('sku') + finishRecord.get('text'),//"MC-3X51073460",=> sizeSkuModifiers + SKU + ColorSKUModifiers
productPrice: finishRecord.get('price'),
productID: productInfoStore.get('productId'),
variantID: finishRecord.get('variantId'),
quantity: '1',
chosenColor: color,
chosenColorSKUModifier: colorSKU,
chosenSize: sizeRecord[0].get('size'),
chosenSizeSKUModifier: sizeRecord[0].get('sizeSkuModifier')
},
success: function(response,opts) {
sessionStorage.setItem('customerId', response.addItemsToCartResult);//store customerId for future use
localStorage.setItem('customerId', response.addItemsToCartResult);
if(cartStoreOffline.getCount() != 0) {
if(!me.offlineCartItemsPanel){
me.offlineCartItemsPanel = Ext.create('Wilsonart.view.tablet.OfflineCartItems');
}
me.offlineCartItemsPanel.show();
}
else {
me.onSuccessAddToCart();
}
Ext.getCmp('addToCart').enable();
},
failure: function(response,opts) {
if (response.timedout) {
Ext.Msg.alert(captions.get('timeout'), captions.get('serverTimeout'));
}
else if (response.aborted) {
Ext.Msg.alert(captions.get('aborted'), captions.get('requestAborted'));
} else {
Ext.Msg.alert(captions.get('bad'), captions.get('invalidRequest'));
}
Ext.getCmp('addToCart').enable();
}
});
It works fine except that it makes multiple entries on the server even I have tapped the button only once. To overcome the situation I disabled the button once it is tapped and I am enabling it only after receiving response from server. but it also doesn't works.
Please help me.
Sencha - Senior Forum Manager
If it's only being executed only once then there will only be one request. Is it being executed more than once?
Thanks Mitchell. I found the problem. It was sending multiple request when I was testing the app on browser(I don't now why?). but it was running fine on iPad.
Sencha is used by over two million developers. Join the community, wherever you’d like that community to be
or Join Us