Corona SDK获得网络响应

时间:2015-06-05 13:57:01

标签: http networking get request corona

我必须能够与请求的网络地址中的servlet接口并获取此请求的结果但不起作用

代码:

function onLoginBtnRelease(event)
        network.request( "http://localhost/foodingame/searchPlayer?userName="..utente.text.."&password="..password.text, "GET", networkListener )
    end


    local function networkListener( event )

      if ( event.isError ) then
        print( "Network error!")
      else
       local myNewData = event.response
        print ("From server: "..myNewData)
       local decodedData = (json.decode( myNewData))
       if(decodedData.find(utente.text)) then
            messaggio.text = "Persona trovata"
            else
            messaggio.text = "Persona non trovata"
        end
     end
    end

1 个答案:

答案 0 :(得分:0)

您必须先声明networkListener函数,然后才能使用它。只需翻转功能的顺序。