|
|
|
|
|
- Usage example of the AJAXExecute function
Usage example of the AJAXExecute function This example is used to return a complex structure in a procedure called in AJAX to exploit the result in a browser procedure.
sZone is string
sZone = AJAXExecute(ajaxStraightCall, ServerProcReturnJsonData, "Eiffel Towel")
EXTERN JSON
stZone is object dynamic = JSON.parse(sZone)
IF NOT stZone.bFound THEN
Info("Zone not found", stZone.sErrorMessage)
ELSE
APosition is geoPosition
FOR n = 1 _TO_ stZone.aaCoordinates..Count
APosition.Latitude = stZone.aaCoordinates[n].rLatitude
APosition.Longitude = stZone.aaCoordinates[n].rLongitude
MapAddMarker(MAP_Plan, APosition)
END
APosition.Latitude = stZone.stCenter.rLatitude
APosition.Longitude = stZone.stCenter.rLongitude
MapDisplayPosition(MAP_Plan, APosition)
MAP_Plan..Zoom = stZone.nZoom
ToastDisplay("Zone " + stZone.sZoneName + " displayed")
END
PROCEDURE ServerProcReturnJsonData(...
sParameterZoneName is string <useful="Name of the zone for which to get the coordinates">)
st_MapPoint is Structure
rLatitude is real
rLongitude is real
END
st_DataForBrowserCode is Structure
sZoneName is string
bFound is boolean
sErrorMessage is string
stCenter is st_MapPoint
nZoom is int
aaCoordinates is array of st_MapPoint
END
stResForPage is st_DataForBrowserCode
stAPoint is st_MapPoint
stResForPage.sZoneName = sParameterZoneName
stResForPage.bFound = True
stPoint.rLatitude = 48.860501
stAPoint.rLongitude = 2.295683
ArrayAdd(stResForPage.aaCoordinates, stAPoint)
stPoint.rLatitude = 48.859352
stAPoint.rLongitude = 2.297374
ArrayAdd(stResForPage.aaCoordinates, stAPoint)
stPoint.rLatitude = 48.856397
stAPoint.rLongitude = 2.293040
ArrayAdd(stResForPage.aaCoordinates, stAPoint)
stPoint.rLatitude = 48.857478
stAPoint.rLongitude = 2.291176
ArrayAdd(stResForPage.aaCoordinates, stAPoint)
stResForPage.stCenter.rLatitude = 48.858288
stResForPage.stCenter.rLongitude = 2.294453
stResForPage.nZoom = 15
bufJson is Buffer
Serialize(stResForPage, bufJson, psdJSON)
RETURN bufJson
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|