I want to provide a dropdown list with the ABN number (Its an Australian Business Number ... a unique number for each company in Australia)... The customer enters the company name ... a search button is clicked and an ajax call runs the xbasic on the server that executes a http_get_page2 to return the data and populate a dropdown box with the data from the web site ... If I run the code as a 'function' it works properly ... if a run the code but switch it around and let it return 'manually' what it returns as a 'function' ... it does everything correctly ...
When it runs as a 'function' that works correctly... but when it runs as an ajax callback it does not..
unction LoadABN as c (e as p)
dim js as c
Srch = e._currentRowDataNew.SearchCompany
if Srch <> "" then
Src = strtran(*HTML_ESCAPE(Srch)," ","+")
SrcString = "http://abr.business.gov.au/SearchByName.aspx?SearchText="+ Src
Pg = http_get_page2(SrcString)
sts = "<table id="+ chr(34)+"PartyListView_GridViewParties"+ chr(34)+" style="+ chr(34)+"border-width:0px;"+ chr(34)+">"
ste = "</table>"
xPg = extract_string(Pg,sts,ste)
Lst = ""
for x = 1 to 8
y = (x-1)*4
ABN1 = extract_string(extract_string(xPg,"<a","</a>",x),"abn=",chr(34) + ">")
ABN2 = extract_string(extract_string(xPg,"<td>","</td>",y+1),">","</a>")
ABNStatus = extract_string(extract_string(xPg,"<td>","</td>",y+1),"<span class="+chr(34)+"active"+chr(34)+">","</span>")
LegalName = *HTML_UNESCAPE(alltrim(extract_string(xPg,"<td>","</td>",y+2)))
AddLoc = *HTML_UNESCAPE(alltrim(extract_string(xPg,"<td>","</td>",y+4)))
AddLoc = strtran(AddLoc," "," ")
Lst = Lst + "[["+ABN2+"],["+LegalName+"-"+AddLoc+"-"+ABN1+"-"+ABNStatus+"]],"
next x
ABNList="["+left(Lst,len(Lst)-1)+"]"
js = "{dialog.Object}.populateDropdownBox('ABN',"+ABNList+",true);"
' js = "{dialog.Object}.populateDropdownBox('ABN',[['94 028 163 574','A1 Auto Air-3356 VIC-94028163574-Active'],['15 645 503 845','A1 Auto Air-3356 VIC-15645503845-Active']],true);"
else
msg = "You need to provide Text for the search"
js = "alert('" + js_escape(msg) + "');"
end if
debug(1)
LoadABN = js
end function
When it runs as a 'function' that works correctly... but when it runs as an ajax callback it does not..
unction LoadABN as c (e as p)
dim js as c
Srch = e._currentRowDataNew.SearchCompany
if Srch <> "" then
Src = strtran(*HTML_ESCAPE(Srch)," ","+")
SrcString = "http://abr.business.gov.au/SearchByName.aspx?SearchText="+ Src
Pg = http_get_page2(SrcString)
sts = "<table id="+ chr(34)+"PartyListView_GridViewParties"+ chr(34)+" style="+ chr(34)+"border-width:0px;"+ chr(34)+">"
ste = "</table>"
xPg = extract_string(Pg,sts,ste)
Lst = ""
for x = 1 to 8
y = (x-1)*4
ABN1 = extract_string(extract_string(xPg,"<a","</a>",x),"abn=",chr(34) + ">")
ABN2 = extract_string(extract_string(xPg,"<td>","</td>",y+1),">","</a>")
ABNStatus = extract_string(extract_string(xPg,"<td>","</td>",y+1),"<span class="+chr(34)+"active"+chr(34)+">","</span>")
LegalName = *HTML_UNESCAPE(alltrim(extract_string(xPg,"<td>","</td>",y+2)))
AddLoc = *HTML_UNESCAPE(alltrim(extract_string(xPg,"<td>","</td>",y+4)))
AddLoc = strtran(AddLoc," "," ")
Lst = Lst + "[["+ABN2+"],["+LegalName+"-"+AddLoc+"-"+ABN1+"-"+ABNStatus+"]],"
next x
ABNList="["+left(Lst,len(Lst)-1)+"]"
js = "{dialog.Object}.populateDropdownBox('ABN',"+ABNList+",true);"
' js = "{dialog.Object}.populateDropdownBox('ABN',[['94 028 163 574','A1 Auto Air-3356 VIC-94028163574-Active'],['15 645 503 845','A1 Auto Air-3356 VIC-15645503845-Active']],true);"
else
msg = "You need to provide Text for the search"
js = "alert('" + js_escape(msg) + "');"
end if
debug(1)
LoadABN = js
end function
Comment