EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: JDMcQ on January 24, 2015, 08:15:16 AM



Title: loading Data from a multiple function PHP file
Post by: JDMcQ on January 24, 2015, 08:15:16 AM
I have no problem getting a Data grid to load data with a .php file, but I don't want to have a separate file for every Grid load etc.

So my attempted solution was to pass the name of the function in a POST var.But EasyUI completely ignores everything at this point. See Code below.

Code:
	$CID = isset($_POST['CatID']) ? intval($_POST['CatID']) :0;
$Func = isset($_POST['fn']) ? $_POST['fn'] :'Bad';

if ($Func == 'PT')
PTable ($CID);

if ($Func == 'Bad')
PTable ($CID);

function PTable($CID){
$result = array();

The PTable function works great asl long as it's not in a function.

Please help.



Title: Re: loading Data from a multiple function PHP file
Post by: yamilbracho on January 24, 2015, 04:43:37 PM
How do you build the url ?

table id="dg"
   url=".your.php?CatID=1&fn=MyFunc"
...>

as you are using this particular URL the parameters came in the $_GET array and not in $_POST so you have to fix your code to
   $CID = isset($_GET['CatID']) ? intval($_GET['CatID']) :0;
   $Func = isset($_GET['fn']) ? $_$_GET['fn'] :'Bad';

or use $_REQUEST
   CID = isset($_REQUEST['CatID']) ? intval($_REQUEST['CatID']) :0;
   $Func = isset($_REQUEST['fn']) ? $_$_REQUEST['fn'] :'Bad';


HTH
Yamil


Title: Re: loading Data from a multiple function PHP file
Post by: JDMcQ on January 24, 2015, 06:38:50 PM
Actually I'm using POST. Therefore I'm not placing anything in my url except the page. When code is not within a function I can report the 'fn' value and 'CID' value in the grid as soon as I put the code into a function, nothing works. Have you been able to use GET to do this? P.S. thanks for responding.


Title: Re: loading Data from a multiple function PHP file
Post by: yamilbracho on January 24, 2015, 10:36:16 PM
The URL trick works for me...
And place an alter or console.log to verify if your function is called...

Regards,
Yamil


Title: Re: loading Data from a multiple function PHP file
Post by: JDMcQ on January 25, 2015, 08:36:35 AM
I would really like to use the "queryParams" function to pass the data (and function name).
My understanding is that this is via POST. Question: can I GET & POST in the same call?  The function will be the same so I can attach that to the URL,
but the CID will change on every call, so the "queryParams" works really well for that.

Having a look at the console did reveal something interesting though. I see that the error references "fn" which happened to be my POST variable name
so I changed it to "ff" in case I had stumbled upon a reserved word. No change.
Here is the console output, what does it mean?
Code:
 POST
 http://192.168.1.165/phpfiles/FTest.php 500 (Internal Server Error)         jquery-1.4.4.min.js:141
 c.extend.ajax       jquery.easyui.min.js:10127
 $.fn.datagrid.defaults.$.extend.loader           jquery.easyui.min.js:9418
 _6c6                jquery.easyui.min.js:9415
 (anonymous function)


Title: Re: loading Data from a multiple function PHP file
Post by: JDMcQ on February 07, 2015, 08:20:11 PM
So I see I have stumped everybody!! ???

Anybody have a sample of a DataGrid Loader function that calls PHP? Maybe I could use that??? I really don't want to have to go looking for another UI solution.