live demo:
https://www.modharbour.org/modharbour_s ... to_prg.prg
source code:
https://github.com/FiveTechSoft/mod_har ... to_prg.prg
We also provide the demo to convert Harbour hashes into javascript objects:
live demo:
https://www.modharbour.org/modharbour_s ... _to_js.prg
source code:
https://github.com/FiveTechSoft/mod_har ... _to_js.prg
This way you clear understand how to send values from Harbour to javascript and from javascript to Harbour
Harbour for the web power!
Sending javascript objects to Harbour hashes
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Sending javascript objects to Harbour hashes
Hello Antonio,
what is the way to access localStorage.getItem() /and other javascript objects/ directly from mod_harbour code?
Taavi.
what is the way to access localStorage.getItem() /and other javascript objects/ directly from mod_harbour code?
Taavi.
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Sending javascript objects to Harbour hashes
Taavi,
Code: Select all
function Main()
LocalStorageSetItem( "Name", "Taavi" )
ShowLocalStorageItem( "Name" )
return nil
function LocalStorageSetItem( cKey, cValue )
return AP_RPuts( "<script>localStorage.setItem( '" + cKey + "','" + cValue + "')</script>" )
function ShowLocalStorageItem( cKey )
return AP_RPuts( "<script>alert( localStorage.getItem( '" + cKey + "') )</script>" )
Re: Sending javascript objects to Harbour hashes
Is it possible to get value instead of showing it with js alert?
Something like this?
function Main()
local cname
LocalStorageSetItem( "Name", "Taavi" )
cname:=LocalStorageGetItem( "Name" )
return nil
Something like this?
function Main()
local cname
LocalStorageSetItem( "Name", "Taavi" )
cname:=LocalStorageGetItem( "Name" )
return nil
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Sending javascript objects to Harbour hashes
Dear Taavi,
The PRG runs on the server, where there is no "localStorage".
The "locaStorage" lives in the client side, where there are no PRGs, and we only have HTML and javascript.
When you use LocalStorageGetItem( "Name" ), we are creating a javascript script that will run on the client side.
So there is no way to assign its result to a PRG variable as by that time mod_harbour has ended its work and the action is at the client side.
What you can do is to send the value in "localStorage" back to the server, exactly using the technique that I have posted in this thread.
The PRG runs on the server, where there is no "localStorage".
The "locaStorage" lives in the client side, where there are no PRGs, and we only have HTML and javascript.
When you use LocalStorageGetItem( "Name" ), we are creating a javascript script that will run on the client side.
So there is no way to assign its result to a PRG variable as by that time mod_harbour has ended its work and the action is at the client side.
What you can do is to send the value in "localStorage" back to the server, exactly using the technique that I have posted in this thread.
Re: Sending javascript objects to Harbour hashes
Thanks. Antonio.
...just wanted to be sure there is no other way...
Seems we've got our first simple mod_harbour project up and running . Keep learning here...
Taavi.
...just wanted to be sure there is no other way...
Seems we've got our first simple mod_harbour project up and running . Keep learning here...
Taavi.