Quantcast
Channel: Adobe Community : Popular Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 14291

Ajax call method which return json Data

$
0
0

Hi, I make one function , which i want to return json value , for this which return type i mention in function:

 

This is javascript which call Retrieve method.

<script>

debugger;

         var remoteDatasource = new kendo.data.DataSource({

             transport: {

                 read: {

  type:"POST",

  url: "Controllers/Home.cfc",

  dataType: "json",

                     data: {

  method: "Retrieve",

                         dataLists: JSON.stringify(request)

                     }

                 }

             },

</script>

Home.cfc

component

{

remote   function Retrieve(string dataLists)

  {

  try

  {

            q = new Query();

            q.setsql("SELECT * FROM Product");

            qResult = q.execute().getresult();

            col_len = ListLen(qResult.Columnlist);

            dataArray = ArrayNew(1);

            row = 0;

            col = 0;

            for(row = 1; row <= len; row++)

            {

                 for(col = 1; col <= col_len; col++)

                 {

                      FieldName = ListGetAt(qResult.Columnlist, col);

                      dataArray[row][col] = qResult[FieldName][col];

                 }

            }

      jsonvar=serializeJSON(dataArray);

  }

  catch(any e)

  {

  }

return jsonvar;

  }

}


Viewing all articles
Browse latest Browse all 14291

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>