Talk:AJAX - Return Arrays and Structs to your JavaScript with XML

From DataFlex Wiki
Revision as of 15:07, 19 December 2008 by Jka (talk | contribs) (New page: From Akennard: I just wanted to ask 'why' this works .... Get paXml of hoXml to aXml Send Destroy of hoRoot Send Destroy of hoXML Function_Return aXML End_Function ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

From Akennard:

I just wanted to ask 'why' this works ....



 Get paXml of hoXml to aXml
 Send Destroy of hoRoot
 Send Destroy of hoXML	
 Function_Return aXML

End_Function

Is it because VDF does not ACTUALLY destroy and objects untill it gets to end_function ? because returning a handle to something you have just destroyed doesn't look quite right ? ie you are returning a handle to nothing or something that might still exist at that point ? VDF has a special XmlHandle return type for returning a hoXML object and the tidying up after itself Is there a reason why this has not been used in this case ? eg would this work for AJAX ?

{ Published = True } { Description = "" }

Function NameCasing String sName Returns XMLHandle

 Handle hoRoot hoXML hoEvent
 Address aXml
 // create xml document
 Get Create U_cXMLDOMDocument                            to hoXML
 Set pbValidateOnParse of hoXML                          to False
 Get CreateDocumentElement of hoXML "response"          to hoRoot
 Send AddElement of hoRoot "lowercase" (lowercase(sName))
 Send AddElement of hoRoot "uppercase" (Uppercase(sName))	
 Send AddElement of hoRoot "propercase" (Uppercase(Left(sName,1))+lowercase(Right(sName,(length(sName)-1))))	
 Function_Return hoXML  // runtime will transfer and then destroy this object because of XMLHandle return type

End_Function // NameChanges