Ajax/JQuery?

Topics: Developer Forum, Project Management Forum, User Forum
Coordinator
May 24, 2008 at 1:16 PM
Ajax and JQuery ... YAY!!

Anybody already doing this with ActiveVFP??
May 28, 2008 at 1:36 PM
yes,i am doing that!
Coordinator
May 28, 2008 at 2:14 PM

Lu,

Can you share some code and how you did it?


lugreen1 wrote:
yes,i am doing that!



Coordinator
Jun 8, 2008 at 3:27 PM
Here's one that I just did that was pretty simple:

http://70.174.154.175:443/avfpchat/default.aspx

Here's the fox code:
***********************************
* Mainline entry point of the app
***********************************
#DEFINE crlf CHR(13)+CHR(10)

LOCAL lcXMLout,status_code,lcHTMLfile,lcHTMLout
AVFPinit() && set data and HTML paths
 
IF oRequest.ServerVariables("REQUEST_METHOD") =="GET"
    lcHTMLfile = 'index.html'
	lcHTMLout= FILETOSTR(oProp.HtmlPath+lcHTMLfile)
	lcHTMLout= oHTML.mergetext(lcHTMLout)
	RETURN lcHTMLout
ELSE &&post
    	
	IF !FILE(oProp.DataPath+"messages.dbf")
	    CREATE table oProp.DataPath+"messages"(id i AUTOINC unique,user c     (254),msg M,time T)
	ENDIF
	IF !USED("messages")
		USE messages IN 0 SHARED
	ENDIF
	SELECT messages

	IF oRequest.FORM("action")=="postmsg"
	 	INSERT INTO messages(user,msg,time) VALUES (oRequest.FORM("name"),oRequest.FORM("message"),DATETIME())
 *DELETE FROM messages WHERE id >1&&<= (cnt(id)-store_num)
	ENDIF

	SELECT user,msg FROM messages ;
	            WHERE time>CTOT(oRequest.FORM("time"));
	            ORDER BY id ASC ;
	             into cursor mymessages
	  
	IF RECCOUNT() == 0 
		status_code = 2 &&no new messages
	else 
	    status_code = 1 
	ENDIF
	lcXMLout= [<?xml version="1.0"?>]+crlf;
	+ "<response>"+crlf; 
	+ " <status>"+TRANSFORM(status_code)+"</status>"+crlf; 
	+ " <time>"+TTOC(DATETIME(),3)+"</time>"+crlf


	IF status_code == 1
	    SELECT mymessages
		SCAN 
	 	  	lcXMLout =lcXMLout+ " <message>" +crlf; 
	 		+" <author>"+mymessages.user+"</author>"+crlf; 
			+" <text>"+mymessages.msg+"</text>"+crlf; 
	 		+" </message>"+crlf 
		ENDSCAN 
	ENDIF
	lcXMLout =lcXMLout+ "</response>"
	oResponse.ContentType = "text/xml"
	RETURN lcXMLout
ENDIF
> > The original PHP version is here: Easy Ajax with jQuery