Not sure what to do.....can I run this by you guys?

Charles Warwick charles at
Fri Mar 16 10:48:03 CET 2018

 Hi Tom,

If the site you are trying to contact has CORS enabled appropriately, then you can do something like this...

With the LiveCode browser widget, you can call JavaScript functions from LC script and have the JavaScript functions call LC handlers in return.  JavaScript has the capability to perform asynchronous HTTP requests.

You can create a HTML page that you automatically load up in the browser widget that has a small JavaScript function which you can call from LC with ‘do in widget’.   All this function needs to do is issue an asynchronous HTTP call to the URL passed to it as a parameter and when it receives the data, return it back to your LC script by calling a nominated LC handler and passing the returned data as a parameter.

The HTML page would look something like this:

<title>Javascript Async Test</title>
<script type="text/javascript">

function httpGetAsync(theUrl)
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.onreadystatechange = function() { 
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
            liveCode.httpRequestComplete(theUrl, xmlHttp.responseText);
    }"GET", theUrl, true); // true for asynchronous 

You can either load that from a file into the browser widget’s URL or set its htmlText property accordingly...

Then in LC, make sure you register the httpRequestComplete handler so that the widget can call it:

set the javascriptHandlers of widget “browser” to “httpRequestComplete”

After that, add a httpRequestComplete handler to the card script to handle the returned data:

on httpRequestComplete pUrl, pData
   — pUrl will be the URL requested
   — pData will be the data returned from the URL requested
end httpRequestComplete

Lastly, make your async requests....

do (“httpGetAsync(‘’);” in widget “browser”

Since the JavaScript in the browser widget is issuing the requests and sending the data back to LC, it doesn’t need to display anything related to it in the browser widget itself - it can be a blank canvas.

Just be aware that the browser widget can cache URLs and there is no easy way (that I know of?) in LC to clear the browser’s cache... so if you see very quick responses on a second or subsequent request to the same URL, it is likely pulling it all from the browser’s cache.



>> On 16 Mar 2018, at 1:35 pm, Tom Glod via use-livecode <use-livecode at> wrote:
>> Great hints there Mike .... thanks alot.  Luckily I'm desktop only right
>> now.
>> It shouldn't be too long before I sit down to make something that I can
>> rely on and reuse in future projects.
>> Might turn out I will have to hire someone to help which is cool too.
>> It only has to be very simple..and does not need to match performance of
>> Tsnet.
>> Anything more than 1 would be a great start. LOL.
>> I will look into the libURL library and then try to guess which way I
>> should go my first attempt to hack this.
>> I'll keep you guys posted on the progress..I think I need a name for this
>> little project.
>> Thanks you
>> Tom

More information about the use-livecode mailing list