1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    14
    Vote Rating
    0
    manvinder is on a distinguished road

      0  

    Default 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.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,684
    Vote Rating
    435
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    If it's only being executed only once then there will only be one request. Is it being executed more than once?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    May 2012
    Posts
    14
    Vote Rating
    0
    manvinder is on a distinguished road

      0  

    Default


    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.