Yes,

you can do "load URL ..." and it will load in the background.

Then either do

1.  "get url ..." as before - and it will used the now-cached version

2. use 'load url ... with message "myhandler" and your handler will be called to let you know when it is ready

3. use urlstatus to check if/when it is ready.


(Simplest, unless there is more going on than you described would be (1). The 'get url ...' will pause only until the initial load is completed.)

Alex.

On 08/09/2025 18:41, jbv via use-livecode wrote:
Hi list,

I have a LC script on a server that computes different
things, and also sends a request to an API to get some data.
More specifically, the script begins with some code that
outputs some result, then needs to send the API request
to get some data to run some more code.
The first part of the script is self-contained (it doesn't
need any extra data to run), while the second part of the
script can't run without the data from the API.
At the end, the results from both parts of the script are
combined into a json.

I am using "get URL" for the request and need to keep the
whole thing as fast as possible, despite the fact that the
API can take 1 to 3 seconds to return data.
I decided to have the first part of the script running
simultaneously with the API request, but since "get URL" is a
blocking command, I use a workaround as follows :

LC script :
   get URL "https://my-PHP-script";
/*
   first part of the code
*/
   -- read API data from DB
   -- perform second part of the code

my-PHP-script :
<?php
  echo "ok";
  // send request to API
  // write API data into DB

I have tested it and it works, but I was wondering if
there is some more elegant way to achieve the same thing...

Thank you in advance.
jbv

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to