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
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 ---
Thanks Rick, I'll give it a go 😃
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 ---
Thank you so much Rick this is really helpful 😃
Is there a modern way of storing the hashtag when the page changes? It would seem there should be a way of using the ES6 "fetch()" function to store the hashtag array? I'm using a routine from the book "Single Page Application" from 2014 - which Works but there must be something better.
Not sure what you're asking or saying in relation to Chris' question here...
fetch()
is fine as long as you're dealing with new browsers. Older devices and anything IE won't work with the fetch()
API so using it is still a bit iffy (although getting a lot less so).
I'm not sure what you mean by 'storing a hashtag'. You mean adding it to the history? There's the pushState API that can be used to push URLs onto the history stack.
+++ Rick ---