Page 2 of 2
Re: Generating JSON File performance problem
Posted: Wed Aug 05, 2020 4:29 pm
by Peter
menschmarkus wrote:Do you have a similar simple JS script for SB like the one for uploading files?
Code: Select all
! window.location.href = "http...";
simple enough?
Greetings ... Peter
Re: Generating JSON File performance problem
Posted: Thu Aug 06, 2020 7:30 am
by menschmarkus
UUhhhhh
Live can be sooooooo easy
Thanks Peter
Edit:
Live is not that easey as it looks like
I stored my file (JSON file) to my server, give back the url to SB app and called the JS line. It is not that this line is not working but it does not download the file, it shows the json result in the browser. I would like to offer it for downloading, not for showing.
Code: Select all
! v_filename = v_fname.name
! window.location.href = "http.../" + v_fname;
Where is my fault?
Re: Generating JSON File performance problem
Posted: Thu Aug 06, 2020 11:41 am
by Peter
menschmarkus wrote:I would like to offer it for downloading, not for showing.
This should work:
Code: Select all
Procedure Callback(Success, Result.s)
If Success
! var a = document.createElement('a');
! var blob = new Blob([v_result], {'type':'application/json'});
! a.href = window.URL.createObjectURL(blob);
! a.download = "filename.json";
! a.click();
EndIf
EndProcedure
HTTPRequest(#PB_HTTP_Get, "http://spiderbytes.tuebben.de/test.json", "", @Callback())
(Please remember to set the "Access-Control-Allow-Origin" on your server accordingly.)
Greetings ... Peter
Re: Generating JSON File performance problem
Posted: Thu Aug 06, 2020 12:46 pm
by menschmarkus