Hello,
I have a client side javascript and need to call a server side javascript from that.
I can not find any documentation and don't know, how to do that.
Thanks a lot
Manfred
Call server side javascript
Moderators: Jon, Steve, Ian, Dave
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
Manfred,
The next Ebase release (V4.5) will introduce the ability to call server-side Javascript directly from client Javascript. But until then, you have to use some sort of indirect technique. Which one depends on what you want to achieve. For example:
Invoke a click on something else on your page (button, image etc) using the jquery click() event. If necessary you can set the display:none CSS property. This gives you the ability to trigger a server event which can then run a server script, but you can't get any response back.
To get a response, you need to set up an Integration Service (Ebase web service), and then call this from your client.
Another technique used to supply information to client Javascript is to include form fields and/or tables on the page, again using display:none to make them invisible. Then extract the form field values by navigating the DOM on the client.
Regards
Jon
The next Ebase release (V4.5) will introduce the ability to call server-side Javascript directly from client Javascript. But until then, you have to use some sort of indirect technique. Which one depends on what you want to achieve. For example:
Invoke a click on something else on your page (button, image etc) using the jquery click() event. If necessary you can set the display:none CSS property. This gives you the ability to trigger a server event which can then run a server script, but you can't get any response back.
To get a response, you need to set up an Integration Service (Ebase web service), and then call this from your client.
Another technique used to supply information to client Javascript is to include form fields and/or tables on the page, again using display:none to make them invisible. Then extract the form field values by navigating the DOM on the client.
Regards
Jon
0 x
-
- Ebase Staff
- Posts: 89
- Joined: Mon Sep 10, 2007 11:48 am
Another trick for making server-side field values available to client-side javascript is to use && substitution in your HTML++ (Form Properties -> Web Resources).
For example, define a field called F1 on your form, then in the HTML++:
This will set F1 as a globally (well, globally within the context of your application) accessible javascript variable.
You can extend the idea to pass in text values containing JSON object notation which you simply evaluate to set up the objects on the client side. For example, in server-side javascript:
and then in the HTML++:
NB. You can use HTML++ at the page, form or presentation template level.
For example, define a field called F1 on your form, then in the HTML++:
Code: Select all
<script>var F1 = "&&F1";</script>
You can extend the idea to pass in text values containing JSON object notation which you simply evaluate to set up the objects on the client side. For example, in server-side javascript:
Code: Select all
fields.EMPLOYEES.value= '{ "employees" : [' +
'{ "firstName":"John" , "lastName":"Doe" },' +
'{ "firstName":"Anna" , "lastName":"Smith" },' +
'{ "firstName":"Peter" , "lastName":"Jones" }' +
']}';
fields.ADDRESSES.value = '{' +
'"name":"John Johnson",' +
'"street":"Oslo West 555",' +
'"age":33,' +
'"phone":"555 1234567"' +
'}';
Code: Select all
<script>
var employeesObject = eval ("(" + '&&EMPLOYEES' + ")");
var addressesObject = eval ("(" + '&&ADDRESSES' + ")");
alert(employeesObject.employees[0].firstName);
alert(addressesObject.street);
</script>
NB. You can use HTML++ at the page, form or presentation template level.
0 x
Who is online
Users browsing this forum: No registered users and 3 guests