Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

nuRunHiddenPHP

Questions related to using nuBuilder Forte.
Locked
alf1976
Posts: 75
Joined: Tue Dec 26, 2017 8:58 pm

nuRunHiddenPHP

Unread post by alf1976 »

In the JavaScript on the form i have the following code

Code: Select all

var operationdata = 0;
nuSetProperty('GetOperationID', '6');  // set hash for php function
nuRunPHPHidden('GetOperationInfo', 1); //load data as JSON string and load into operationdata
console.log('Data: ',operationdata);
UpdateOrientation(); // updated orientation display field
UpdateSubCompOpacity(); // update opacity on new subform row.
UpdateComponentQty(); // relculate subform costs.

The PHP procedure has a java script callback which is

Code: Select all

$js = "
    operationdata = $result;
    ";
The callback does populate the operationdata with the information but not until (it appears) the entire JavaScript for the form has run.
So by the time it has received the data all the caculations have finished.

Is there away to process the java script on the callback as soon as the nuRunPHPHidden() has run - ie before the next statement?

Or is there a better way to achieve the above.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuRunHiddenPHP

Unread post by admin »

Andrew,

If I understand you.

You could move your Update functions to the callback.

Code: Select all


var operationdata = 0;

nuSetProperty('GetOperationID', '6');
nuRunPHPHidden('GetOperationInfo', 1);

Code: Select all


$js = "

    operationdata = $result;

    UpdateOrientation(); // updated orientation display field
    UpdateSubCompOpacity(); // update opacity on new subform row.
    UpdateComponentQty(); // relculate subform costs.

    console.log('Updates done!');

    ";


Steven
alf1976
Posts: 75
Joined: Tue Dec 26, 2017 8:58 pm

Re: nuRunHiddenPHP

Unread post by alf1976 »

thanks for the advice. that should change the execution order
i'll give it a try.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuRunHiddenPHP

Unread post by admin »

.
Locked