Generating JSON File performance problem

Just starting out? Need help? Post your questions and find answers here.
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Generating JSON File performance problem

Post 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
menschmarkus
Posts: 37
Joined: Thu Apr 10, 2014 3:35 pm

Re: Generating JSON File performance problem

Post by menschmarkus »

UUhhhhh :shock:
Live can be sooooooo easy :lol:

Thanks Peter


Edit:
Live is not that easey as it looks like :roll:
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?
as soon you do it right, it works !
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Generating JSON File performance problem

Post 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
menschmarkus
Posts: 37
Joined: Thu Apr 10, 2014 3:35 pm

Re: Generating JSON File performance problem

Post by menschmarkus »

:D
as soon you do it right, it works !
Post Reply