AJAX - Return Arrays and Structs to your JavaScript with XML: Difference between revisions
From DataFlex Wiki
Jump to navigationJump to search
(New page: = Functionality = The VDF AJAX Library provides the functionality for developers to call published methods within a WBO and receive a return value (for Functions). This is done using a Re...) |
|||
Line 44: | Line 44: | ||
Function_Return aXML | Function_Return aXML | ||
End_Function // NameChanges | End_Function // NameChanges | ||
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 | |||
= Parsing the XML in JavaScript = | = Parsing the XML in JavaScript = |