Closed seba1rx closed 3 years ago
Hi,
The synchronous request feature is deprecated in javascript, and thus was removed in the last release, and re-implemented with a queue. https://github.com/jaxon-php/jaxon-js/releases/tag/v3.2.0
You can still set some Jaxon requests as synchronous, but they will be queued, and each will be executed only after the response to the previous is received. The return value is not relevant anymore. You can use the response api to set the value of a javascript variable.
function functionThatSetsDataValue(){
$jaxonResponse = new Response();
$data= array(
'isValidated' => TRUE,
'str_data' => 'some data here',
'int_data' => 123,
'flt_data' => 1.23
);
$jaxonResponse->call('setData', $data);
$jaxonResponse->script('console.log(myData)');
return $jaxonResponse;
}
<script>
var myData = null;
function setData(data) {
myData = data;
}
jaxon_functionThatSetsDataValue();
</script>
Hi,
The synchronous request feature is deprecated in javascript, and thus was removed in the last release, and re-implemented with a queue. https://github.com/jaxon-php/jaxon-js/releases/tag/v3.2.0
You can still set some Jaxon requests as synchronous, but they will be queued, and each will be executed only after the response to the previous is received. The return value is not relevant anymore. You can use the response api to set the value of a javascript variable.
function functionThatSetsDataValue(){ $jaxonResponse = new Response(); $data= array( 'isValidated' => TRUE, 'str_data' => 'some data here', 'int_data' => 123, 'flt_data' => 1.23 ); $jaxonResponse->call('setData', $data); $jaxonResponse->script('console.log(myData)'); return $jaxonResponse; }
<script> var myData = null; function setData(data) { myData = data; } jaxon_functionThatSetsDataValue(); </script>
tahnk you so much for the explanation, sorry for not having seeing the release description
I have a question about mode synchronous
when I declare a function like:
$jaxon->register(Jaxon::CALLABLE_FUNCTION, 'functionThatReturnsUsing_setReturnValue', ['mode' => "'synchronous'"]);
and the function code is:
but trying to get the
$data
as a function return value like:I am using jaxon v3, and so far the console.log prints
false
and examinating the response preview with browser console $data is being returned injxnrv
section of response.How can I get the $data returned to the myData var as result of my call??
I tried:
<script>jaxon.config.defaultReturnValue = true;</script>
but it just turns the console.log result to true$jaxon->setOption('core.request.mode', "synchronous");
but it does not help to my purpose.In the closed issues there is a similar question that looks old (2017) I tried the solution posted there but it does not seems to work.
Please help me.