EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: karogel on October 07, 2015, 09:01:44 PM



Title: Load Form Data from URL or MySql data
Post by: karogel on October 07, 2015, 09:01:44 PM
Im using this code to load the basic info of client and test load info based on sample ID. The function frm_maker_show works fine but the function loadCIRinfo to load the test info does not work. I've attached the url file get_latestCIRdata.php. Please help

<a href="javascript:void(0)" class="easyui-linkbutton" onclick="loadCIRinfo()" style="width:160px">Load Latest CIR info</a>

<script type="text/javascript">
      function frm_maker_show(){
         var row = $('#dgrid_loanapp').datagrid('getSelected');
         if (row){
            urldata = 'modules/application/get_maker_data.php?id='+row.loanAppID;
            $('#dlg_investigate_maker').dialog('open').dialog('setTitle','Credit Investigation - Maker');
            $('#fm_investigate_maker').form('load',row);
            url = 'modules/application/update_investigate_maker.php?id='+row.loanAppID;
         }
      }
      
      function loadCIRinfo(){
                     var newLoanID = 944;
           urldata = 'modules/application/get_latestCIRdata.php?id='+newLoanID;
           $('#fm_investigate_maker').form('load',urldata);
      }


//=== get_latestCIRdata.php ======

<?php
   include '../data/conn.php';
   $id = intval($_REQUEST['id']);
   
   $rs = mysql_query("select *, DATE_FORMAT(appdate,'%d/%m/%Y') from tblloanapp app left join tblmasterdata master on app.makermasterDataID=master.masterdataid
                  where loanAppID=" . $id );
   $rows = array();

   while($r = mysql_fetch_assoc($rs)) {
     $rows[] = $r;
   }

   echo json_encode($rows);   

?>


Title: Re: Load Form Data from URL or MySql data
Post by: stworthy on October 08, 2015, 01:47:22 AM
The json result returned from 'get_latestCIRdata.php' should be a single object instead of an array objects.


Title: Re: Load Form Data from URL or MySql data
Post by: karogel on October 08, 2015, 01:50:24 AM
It works. thank you..here's my code:

   include '../data/conn.php';
   $id = intval($_REQUEST['id']);
   
   $rs = mysql_query("select *, DATE_FORMAT(appdate,'%d/%m/%Y') from tblloanapp app left join tblmasterdata master on app.makermasterDataID=master.masterdataid
                  where loanAppID=" . $id );

   $result = mysql_fetch_array($rs);
   echo json_encode($result);