EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: toates on June 04, 2015, 04:29:53 AM



Title: Form not loading via URL
Post by: toates on June 04, 2015, 04:29:53 AM
When using the following code to load a form with data it works just fine:

               $('#'+formType+'dlg').dialog('open').dialog('setTitle','Update');
               $('#'+formType+'fm').form('load',{CONTROL_ID:522,CONTROL_NAME:'Test'});
               $('#'+formType+'fm').form('validate');

When I code the following to use a URL to load the form, the URL which returns the exact same string, the form fails to load with data:

               $('#'+formType+'dlg').dialog('open').dialog('setTitle','Update');
               $('#'+formType+'fm').form('load','Control_SelectDirect.php');
               $('#'+formType+'fm').form('validate');

Here is the contents of the URL file 'Control_SelectDirect.php'

               <?php
               print "{CONTROL_ID:522,CONTROL_NAME:'Test'}";
               ?>

The way I read the documentation I should be able to use a URL to load a form, correct? What am I doing wrong?


Title: Re: Form not loading via URL
Post by: stworthy on June 04, 2015, 06:55:04 AM
Please try
Code:
<?php
echo "{\"CONTROL_ID\":522,\"CONTROL_NAME\":\"Test\"}";
?>


or

Code:
<?php
$a 
= array();
$a['CONTROL_ID'] = 522;
$a['CONTROL_NAME'] = 'Test';
echo 
json_encode($a);
?>



Title: Re: Form not loading via URL
Post by: toates on June 04, 2015, 07:45:56 AM
That worked. However that was just a stub dynamic php to resolve the real problem of my dynamic php select url not populating the form. A little more investigation showed that the JSON result set was returning a set

     [{CONTROL_ID:522,CONTROL_NAME:'Test'}]

with brackets included when the form was expecting just a single item.