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
    310
    Vote Rating
    50
    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

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar