B4J Question how to responr data to ajax post request

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi
I use following code post request from fornt-end browser. My sever handle could receive but i cann't send "123" to the data field of the front-end.

front-end browser code ...
B4X:
$.ajax({
                url : "valuewrite",
                type: "POST",
                data : "out1=1",
                success: function(data, textStatus, jqXHR) {
                    //data - response from server                     <<<---- how could i pass something to data field from b4j
                },
                error: function (jqXHR, textStatus, errorThrown) {
                }
            });

My b4j server handle code ...
B4X:
Sub Handle(req As ServletRequest, resp As ServletResponse)
    Dim s1 As String=req.GetParameter("out1")
    Log("history method:"&s1)
   
    Select s1
        Case "out1"       
                           
        Case "out2"               
           
        Case "out3"
           
        Case "out4"
           
    Case Else
        Return
    End Select
    'create a JSON response   
    resp.ContentType = "application/json"
    resp.Write("123")   
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…