B4J Question How to pass map data to server side ?

jinyistudio

Well-Known Member
Licensed User
Longtime User
How do i call javascript function from browser and then pass map variable to b4j server ?
 

MathiasM

Active Member
Licensed User
You cannot send a map, as Javascript doesn't 'understand' b4j maps. Javascript cannot create them.

It highly depends on what you want to do, but most of the time, you will create a JSON string in Javascript, send that with Ajax in a POST request to your server. (See this page for an intro to POST requesting with Javascript: https://www.w3schools.com/xml/ajax_xmlhttprequest_send.asp)

Your B4J server should receive this json, and convert it to a Map with the Json library.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Or use B4xSerializator and its CovertObjectToBytes function to convert a map to an array of bytes and PostBytes them to your B4J server which will make use of ConvertBytesToObject to read back the original map
 
Upvote 0

udg

Expert
Licensed User
Longtime User
oops, you're right.. I missed the "javascript" reference
BTW, I'm bit confused now.
Is there a B4J UI program that uses a web browser object to run some javascript on a remote website and then have to send to a B4J server the result of that interaction in the form of a Map?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…