B4J Question browser send ajax/get to B4J

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi
following is my current code, Using B4j to refresh browser side page data every fixed timimg with websocket.

My new application is, How could i refresh page with ajax/get to B4J in fixed timing from browser, I don't use websocket ?

B4J
B4X:
Sub timer2_tick
    dim data As Map
    data.Initialize 

    data.Put("resultc",plc.resultc) ' 結果顏色
    data.Put("resultn",plc.resultn) ' 結果數值
    '  
    ws.RunFunction("refresh_page",Array As Object(data))
    ws.Flush
End Sub

Browser
B4X:
function refresh_page(io)
        {
          
            graphic.setValue('resultc',io.resultc);
            graphic.setValue('resultn',io.resultn);     
          

        };
 

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

I will use Handle to recive browser request. And then respone a map to browser. How to coding like followig io variable ? and then i can use then like io.resulttc,,, in the html file.

browser
B4X:
function refresh_page(io)
        {
         
            graphic.setValue('resultc',io.resultc);
            graphic.setValue('resultn',io.resultn);    
         

        };
to browser.
 
Upvote 0
Top