Page 1 of 1

nuRunHiddenPHP

Posted: Tue Feb 20, 2018 8:58 pm
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.

Re: nuRunHiddenPHP

Posted: Tue Feb 20, 2018 10:00 pm
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

Re: nuRunHiddenPHP

Posted: Tue Feb 20, 2018 10:14 pm
by alf1976
thanks for the advice. that should change the execution order
i'll give it a try.

Re: nuRunHiddenPHP

Posted: Tue Feb 20, 2018 11:40 pm
by admin
.