1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    24
    Vote Rating
    0
    Enrico.Massone is on a distinguished road

      0  

    Default Issue with Ext.util.JSON.encode()

    Issue with Ext.util.JSON.encode()


    Hi everyone,

    I'm facing an issue in using 'Ext.util.JSON.encode( )' method and I don't know how to overcome it.

    This is the situation: I have a grid filled by a data store called branch_store, the grid has got an action column containing a button to delete currently selected row.

    I want to send a JSON string containing currently selected row's id to a php script named 'delete.php': it will delete corresponding record from a table in a database.

    Here's my code:

    Code:
    var rec = branch_store.getAt(rowIndex);
    var id = rec.get('id');
    alert("Id is: "+id);  //Debug code
    var store = Ext.create('Ext.data.ArrayStore', {
                              fields: ['id'],
    			  data : [[id]] 
    		 });
    Ext.Ajax.request({
         url: 'delete.php',
         success: function() { Ext.Msg.alert('Success'); },
         failure: function() { Ext.Msg.alert('Fail'); },
         jsonData: Ext.util.JSON.encode(store.data)
    });
    The code above doesn't work, by using google chrome's javascript console to debug it I obtain the following error message:

    Uncaught TypeError: Cannot call method 'encode' of undefined

    The problem is clearly the argument passed to 'encode' method, but I don't know what should be the correct argument type for that method.

    Can anyone help me ?

    Thanks in advance.

  2. #2
    Touch Premium Member
    Join Date
    Feb 2011
    Location
    NJ
    Posts
    311
    Vote Rating
    52
    droessner is a jewel in the rough droessner is a jewel in the rough droessner is a jewel in the rough

      0  

    Default


    It's just Ext.JSON. Use that instead of Ext.util.JSON. http://docs.sencha.com/ext-js/4-1/#!/api/Ext.JSON

  3. #3
    Sencha User
    Join Date
    May 2012
    Posts
    24
    Vote Rating
    0
    Enrico.Massone is on a distinguished road

      0  

    Default


    Well, it seems it works.
    After modifying code as you suggested the error doesn't appear anymore in javascript console, so I believe that Ajax request to 'delete.php' has been correctly sent.
    Next step is typing a php script to delete selected record....
    Thank you very much for helping me
    greetings from Italy :-)

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi