NetTalk Central

Author Topic: Return data from JavaScript to NetTalk server  (Read 4503 times)

Matthew

  • Full Member
  • ***
  • Posts: 137
    • View Profile
    • Email
Return data from JavaScript to NetTalk server
« on: October 04, 2012, 04:25:43 AM »
Hello

I have embanded html object on my page. From the JavaScript I doing operations on that object using its methods.
How can I pass this information back to the server (using Javascript) and use them in Clarion code on server?

Regards,
Matthew

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Return data from JavaScript to NetTalk server
« Reply #1 on: October 04, 2012, 05:11:56 AM »
Hi Matthew,

The simplest approach is to use the JavaScript function

SetSessionValue('variable','value');

Note that this is case sensitive, so you need to spell it exactly as SetSessionValue.

The next step up would be to use the jQuery ajax.get and axax.post commands. But that will take a bit of research on your side.

cheers
Bruce

Matthew

  • Full Member
  • ***
  • Posts: 137
    • View Profile
    • Email
Re: Return data from JavaScript to NetTalk server
« Reply #2 on: October 04, 2012, 10:36:18 PM »
Thank You Bruce. That exaclty what I need.

I have another question about that. When I will pass some value from JavaScript to NetTalk, then how can I inform NetTalk server that this value was set and NetTalk can use them (ie. execute some clarion code to save this value in database)?

Regards,
Matthew

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Return data from JavaScript to NetTalk server
« Reply #3 on: October 04, 2012, 11:33:03 PM »
It'll "arrive" into the WebHandler procedure. So this is where you'd trap it, and do additional information.

I'd lean towards the _SendFile method, after the parent call, something like this;

if self.pagename = 'SetSessionValue' and self.RequestAjax = 1
  ! parse self.WholeURL and do extra work if required
end


update: I've added a method in 6.47 and later called SessionValueSetFromBrowser. this takes the name, and value as parameters. So you would put your code in here. (and you'd more easily have access to the name, and value so it would be simpler.)

Cheers
Bruce