Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: how to get the value in ext.ajax.request

  1. #1
    Ext User
    Join Date
    Sep 2010
    Posts
    19
    Vote Rating
    0
      0  

    Default how to get the value in ext.ajax.request

    heres my code
    Code:
    Ext.Ajax.request({
      url : 'action/sessionProcess.php',
      params : { action : 'USERTYPE' },
      method: 'POST',
      success: function ( result, request ) { 
          Ext.MessageBox.alert('Success', 'Data return from the server: '+ result.responseText);      
         
      },
      failure: function ( result, request) { 
            Ext.MessageBox.alert('Failed', result.responseText); 
      } 
    });
    the response
    PHP Code:

    my problem is how can i get or retrieve the "result.responseText"
    i tried passing it to a variable but still couldnt retrieve the value ...

    am using that value i retrieve for tbar which is something like this
    Code:
    hidden: usertype !=2 ? true : false
    Any help is greatly appreciated

    Thanks in Advance

  2. #2
    Sencha User darthwes's Avatar
    Join Date
    Mar 2010
    Posts
    633
    Vote Rating
    -12
      0  

    Default

    Code:
    function doSomething(t) {
        Ext.MessageBox.alert('Success', 'Data return from the server: ' + t);
    }
    Ext.Ajax.request({
      url : 'action/sessionProcess.php',
      params : { action : 'USERTYPE' },
      method: 'POST',
      success: function ( result, request ) { 
          Ext.MessageBox.alert('Success', 'Data return from the server: '+ result.responseText);      
          doSomething(result.responseText);
      },
      failure: function ( result, request) { 
            Ext.MessageBox.alert('Failed', result.responseText); 
      } 
    });
    That what you mean?
    Wes

  3. #3
    Sencha User
    Join Date
    Jul 2010
    Posts
    46
    Vote Rating
    0
      0  

    Default

    maybe this one will work

    success:function(response){
    text= response.responseText;
    }

  4. #4

  5. #5
    Sencha User
    Join Date
    Apr 2010
    Location
    Italy
    Posts
    12
    Vote Rating
    0
      0  

    Default

    It's depends on your server response, like mankz said. If you're using PHP, you can use something like this:

    Code:
    $response = array("success" => true, "value" => "ooooooooooook");
    echo json_econde($response);
    And to retrieve the response in ExtJs, you can make something like this:

    Code:
    success:function(response){
                        var data= response.responseText.data;
    alert(data.value);
    }

  6. #6
    Ext User
    Join Date
    Sep 2010
    Posts
    19
    Vote Rating
    0
      0  

    Default

    hi ...

    my server response is 1 coz i only echo 1 in my php

    what i did is
    Code:
    success: function ( response ) { 
          var  usertype = response.responseText;
    }
    but when i start calling usertype variable for the so that if the usertype is 1 the hidden will be true and and if usertype is 2 the hidden will be false

    Code:
    hidden: usertype !=2 ? true : false
    but i got an error message saying when calling the usertype variable

    Code:
    usertype is not define

  7. #7
    Sencha Premium User mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    3,153
    Vote Rating
    203
      0  

    Default

    Ok I think I understand what you mean. Where does this code come from, could you post some more context?

    Code:
    hidden: usertype !=2 ? true : false

  8. #8
    Ext User
    Join Date
    Sep 2010
    Posts
    19
    Vote Rating
    0
      0  

    Default

    heres the code sir
    Code:
    Ext.Ajax.request({
        url : 'action/sessionProcess.php',
        params : { action : 'USERTYPE' },
        method: 'POST',
        success: function ( response ) { 
            
            var usertype = response.responseText;
            alert(usertype);
    
        },
        failure: function ( response ) { 
            Ext.MessageBox.alert('Failed', response.responseText); 
        } 
    });
    
    
    var visitorlistGrid = new Ext.grid.GridPanel({
        id: 'visitor-grid'
        ,store: visitorlistStore
        ,columns: [{ header: "visitorid", width: 30, dataIndex: 'visitorid', hidden:true }
            ,{ header: "Date", dataIndex: 'datevisit', width: 80, align: 'center'}
            ,{ header: "Time In", width: 70, dataIndex: 'timein', align: 'center'}
            ,{ header: "Time Out", width: 70, dataIndex: 'timeout', align: 'center'}
            ,{ id: 'visitor-col', header: "Visitor", width: 190, dataIndex: 'visitorname',	align: 'left'}
            ,{ header: "Contact No.", width: 100, dataIndex: 'contactno',	align: 'left'}
            ,{ header: "Reason", width: 200, dataIndex: 'reason',	align: 'left'}
            ,{ header: "Person To Visit", width: 150, dataIndex: 'employeename',	align: 'left'}
            ,{ header: "Department", width: 150, dataIndex: 'department',	align: 'left'}]
        ,autoExpandColumn: 'visitor-col'
        ,stripeRows: true
        ,layout: 'fit'
        ,loadMask: true	
        ,tbar: [{
            text: 'Log Visitor'
            ,iconCls: 'add'
            ,hidden: usertype !=2 ? true : false  
            ,handler: function(){
                   ............
             }
       }]
    });

  9. #9
    Sencha Premium User mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    3,153
    Vote Rating
    203
      0  

    Default

    Ok, you'll need to programmatically call some method to update the hidden property. Remember that the ajax request is Asynchronous, so the grid code will execute before your ajax request is complete.

    Code:
    Ext.Ajax.request({
        url : 'action/sessionProcess.php',
        params : { action : 'USERTYPE' },
        method: 'POST',
        success: function ( response ) { 
            
            var usertype = response.responseText;
            Ext.getCmp('test').setVisible(usertype == 2);
    
        },
        failure: function ( response ) { 
            Ext.MessageBox.alert('Failed', response.responseText); 
        } 
    });
    
    
    var visitorlistGrid = new Ext.grid.GridPanel({
        id: 'visitor-grid'
        ,store: visitorlistStore
        ,columns: [{ header: "visitorid", width: 30, dataIndex: 'visitorid', hidden:true }
            ,{ header: "Date", dataIndex: 'datevisit', width: 80, align: 'center'}
            ,{ header: "Time In", width: 70, dataIndex: 'timein', align: 'center'}
            ,{ header: "Time Out", width: 70, dataIndex: 'timeout', align: 'center'}
            ,{ id: 'visitor-col', header: "Visitor", width: 190, dataIndex: 'visitorname',	align: 'left'}
            ,{ header: "Contact No.", width: 100, dataIndex: 'contactno',	align: 'left'}
            ,{ header: "Reason", width: 200, dataIndex: 'reason',	align: 'left'}
            ,{ header: "Person To Visit", width: 150, dataIndex: 'employeename',	align: 'left'}
            ,{ header: "Department", width: 150, dataIndex: 'department',	align: 'left'}]
        ,autoExpandColumn: 'visitor-col'
        ,stripeRows: true
        ,layout: 'fit'
        ,loadMask: true	
        ,tbar: [{
            text: 'Log Visitor'
            ,id : 'test'
            ,iconCls: 'add'
            ,handler: function(){
                   ............
             }
       }]
    });

  10. #10
    Ext User
    Join Date
    Sep 2010
    Posts
    19
    Vote Rating
    0
      0  

    Default

    sir how do i do that? ..

    sorry am just new to extjs

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 2
    Last Post: 6 Oct 2010, 5:00 AM
  2. add a param to all Ext.Ajax.request (tree, store, normal Ajax.request)
    By aj3423 in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 26 Jan 2010, 9:18 AM
  3. autoLoad vs Ext.Ajax.request... loadScripts not working w/Ajax.request
    By zhegwood in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 6 Aug 2009, 3:28 PM
  4. Problem in send ajax request :The Ext.Ajax is null or not Object
    By flyingpig in forum Ext 1.x: Help & Discussion
    Replies: 7
    Last Post: 27 Aug 2007, 11:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •