Hi there
I kindly need some help. I have written a sub that's supposed to return the string value from CallAjaxWait as depicted below. I am calling an server php file.
I am calling this from my button click event, and this when logged shows a Promise on the console. One scenario is either I get to process further things on it using a BANano.Promise object as I need to process the results.
Is there a way to pass the res variable to a promise object so that I can get the result of the php result or some other way to access the records returned that are stored in the "value" of the returned promise?
Thanks in advance
I kindly need some help. I have written a sub that's supposed to return the string value from CallAjaxWait as depicted below. I am calling an server php file.
B4X:
Sub ExecutePHPWait(pQuery As Map, phpFile As String, phpTag As String) As String
Dim json As String
Dim sCommand As String = ""
json = Map2QueryString(pQuery)
If Len(json) = 0 Then
sCommand = $"${PhpPath}${phpFile}"$
Else
sCommand = $"${PhpPath}${phpFile}?${json}"$
End If
'create the headers
Dim headers As Map
headers.Initialize
headers.put("Content-Type", "application/json")
headers.Put("Access-Control-Allow-Origin", "*")
Dim result As String = banano.CallAjaxWait(sCommand, "GET", "json","",False, headers)
Return result
End Sub
I am calling this from my button click event, and this when logged shows a Promise on the console. One scenario is either I get to process further things on it using a BANano.Promise object as I need to process the results.
B4X:
Sub loginw(e As BANanoEvent)
Dim strUser As String = banano.GetElement("#txtusername").GetValue
Dim strPwd As String = banano.GetElement("#txtpassword").GetValue
'build php query
Dim straction As String = "validateuser"
Dim dbAction As Map
dbAction.Initialize
dbAction.Put("action=", straction)
dbAction.Put("username=", strUser)
dbAction.Put("userpassword=", strPwd)
'execute php
Dim res As String = ExecutePHPWait(dbAction,"users.php",straction)
Log(res)
Log("Done")
End Sub
Is there a way to pass the res variable to a promise object so that I can get the result of the php result or some other way to access the records returned that are stored in the "value" of the returned promise?
Thanks in advance