Web Connection
Is it possible to call a VFP function without submitting or leaving the current web page
Gravatar is a globally recognized avatar based on your email address. Is it possible to call a VFP function without submitting or leaving the current web page
  Chris Jewell
  All
  Jan 10, 2020 @ 02:49am

Hi Rick,

Hopefully, this is a quick question.

Is it possible to call a VFP function without submitting or leaving the current web page?

What I'm trying to achieve is this, on a web page the user is going to click a timer when they start an action and this DateTime needs to be recorded onto a .dbf without leaving the form.

Any ideas appreciated? Thanks, Chris

Gravatar is a globally recognized avatar based on your email address. re: Is it possible to call a VFP function without submitting or leaving the current web page
  Rick Strahl
  Chris Jewell
  Jan 10, 2020 @ 04:14am

Yes you need to make an asynchronous 'AJAX' call.

There are a number of ways to do this but the simplest is to use ww.jquery.js and the ajaxJson() method that lets you make a call to the server and return a result via JSON.

There aren't any real simple examples, but there's a walk through for creating JSON REST Web Services that demonstrates how to create a service you can call from the browser.

The last topic in that walkthrough talks about how to call the server.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Is it possible to call a VFP function without submitting or leaving the current web page
  Chris Jewell
  Rick Strahl
  Jan 13, 2020 @ 08:10am

Thanks Rick, I'll give it a go 😃

Gravatar is a globally recognized avatar based on your email address. re: Is it possible to call a VFP function without submitting or leaving the current web page
  Rick Strahl
  Chris Jewell
  Jan 13, 2020 @ 12:29pm

I probably made that sound a lot more scary than it is...

Another option is to just use jQuery.ajax() or jQuery.get() to call a separate URL and retrieve some data.

Just wrote up a topic that demonstrates this here:

Using jQuery.get() for Simple Ajax Callbacks

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Is it possible to call a VFP function without submitting or leaving the current web page
  Chris Jewell
  Rick Strahl
  Jan 15, 2020 @ 03:33am

Thank you so much Rick this is really helpful 😃

© 1996-2020