Here are two files which demonstrate AJAX with FoxWeb
The first file, PWEnter.FWX is a page which has a text field that requests a password. The password is checked when you exit the text field using onblur=.
The second file is CheckThePW.FWX which checks the password and returns either YES or NO to PWEnter.FWX. The password is checked using VFP code. Clearly the code can be as complex as you need it to be.
I have this working well in my site so please contact me if you have additional questions.
BTW part of the code that I copied involved building a url with a parameter sid which is set equal to a random number. According to the website that I took the code from, it forces the page to be reloaded because it is different everytime. I has nothing to do with my code or AJAX but I left it in.
Sent by Jim on 07/20/2006 05:36:24 AM:
Please post the code!! I would name children after you...
"The true measure of a career is to be able to be content, even proud that you succeeded through your own endeavors without leaving a trail of casualties in your wake."
Sent by Jeff Grippe on 06/29/2006 12:23:52 PM:
You are right. I did not have to wait.
I have developed a sample FoxWeb/AJAX script and I have documented it.
You are welcome to it or if there is some place for user developed scripts I'd be happy to post it there.
For me the missing link in understanding this was realizing that the server-side app was an FWX script which used response.write to send back its result to the client script.
I now know how to code my password validation routine using AJAX which has the password validation done on the server.
I am grateful for your help and happy to share this code. It is short, simple, and documented!
Sent by FoxWeb Support on 06/29/2006 11:06:30 AM:
Sent by Jeff Grippe on 06/29/2006 02:51:57 AM:
Do you have an AJAX / FoxWeb example?
I read the article that you pointed me to and while I understood the concept and the sample that they provided, I have no idea how this would work with FoxWeb.
Have you considered putting an AJAX / FoxWeb sample on the website?
Sent by FoxWeb Support on 06/28/2006 08:34:17 PM:
Sent by Jeff Grippe on 06/28/2006 12:00:09 PM:
I understand and agree but then I'm faced with the problem of how to do it.
The form is a form that requests from 2 - 4 files for uploading. At the bottom of the form is a text box for password entry and a submit button.
I need to check the password before the user clicks the submit button and uploads the files. If I check the PW on the server then I must upload the files first. This is a long time for my users to have to wait just to find out if they typed the PW correctly.
I offered to design the system so that they validated the PW and then got access to the upload screen but my lawyers are insisting that it all has to be done on one screen.
I'm open to any suggestions.
Sent by FoxWeb Support on 06/28/2006 10:05:17 AM:
Sent by Jeff Grippe on 06/28/2006 08:20:45 AM:
I can not re-organize the page to collect the password somewhere else other than at the time the form is submitted. This is something that my legal department has insisted on.
Sent by FoxWeb Support on 06/27/2006 08:31:45 PM:
In your original message you asked:
My question referred to the password value. I assume that the user enters a userid in the same form that contains the field that asks for the file to be uploaded. Is this correct? If yes, then why not split the forms in two pages. The first page will ask for the userid and password. Once the user clicks the submit button, a script on the server should validate the password and return a subsequent form that asks for the file to be uploaded.
If you don't want to split the forms, then you will need to use AJAX to make a request to the server, without actually submitting the form. I can't teach you how to employ AJAX technology in this forum, but you can look it up on the Web. A quick search will turn up lots of helpful information on this subject. This article is particularly useful: http://developer.mozilla.org/en/docs/AJAX:Getting_Started. In fact, the article contains everything you need to know in order to use AJAX in your FoxWeb scripts.
Sent by Jeff Grippe on 06/27/2006 01:58:07 AM:
I am not sure about the answer to "Do you know the value you are validating against?"
My typical FWX file has the following structure:
* SETUP CODE, GET Session Variables, Open Files, Run Queries, Etc.
I could lookup the password in the setup code but I think that may be too late, or is it? When is the '<%=pswd%>' from your example resolved? Does my setup code run first allowing me to retreive the value from a database
or session variable?
Sent by FoxWeb Support on 06/26/2006 09:47:40 PM:
You could even populate an array with a bunch of values.
If, on the other hand, you are validating against a large set of values (such as your password example), then there are two options:
Sent by Jeff Grippe on 06/26/2006 01:28:51 PM:
I need to validate a form value before the user clicks submit in order to prevent a long file upload when a required password is incorrect.
The form line contains onsubmit="return validate()"
Thank you very much.