Author Topic: Help with parsing JSON recordset - after grid refresh  (Read 2218 times)

gammax500

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 16
    • View Profile
Help with parsing JSON recordset - after grid refresh
« on: January 13, 2016, 10:38:19 pm »
I have a working grid but need to disable an "add" button on the grid toolbar after posted data is inserted into the grid.  To do it, I run a function that gets a recordset from the database and need to parse that JSON to set some local variables.

i know this is simple and really not an issue for the grid itself, but I can't see how to do parse the returned data which looks like:

 {"DATA":[{"logins_remaining":0,"login_count":10}]}

The function is called after the grid refreshes.  Can you provide a hint on how to parse the JSON? 

function refreshLoginCount() {
         
         //get a query recordset of counts from server
      $.get("/_resources/cfc/logins.cfc?method=getActiveLoginCount&account_id=" + $account_id, function(data, status){
 
            // This is the response from server >>   {"DATA":[{"logins_remaining":0,"login_count":10}]}.   
            
            
            // I want to set some Jquery variables, for example >>  $logins_remaining = 0 AND $("#login_count").html("10");
            
            
 
          });
      }

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Help with parsing JSON recordset - after grid refresh
« Reply #1 on: January 13, 2016, 11:26:35 pm »
You could use JSON.parse( )