0
即时通讯和即时通讯试图从MySQL数据库中提取数据并在应用程序中使用该数据。电晕功能和变量
数据提取正确,但我可以在函数外访问它。
功能来获取数据:
function loginCallback(event)
if (event.isError) then
print("Network error!")
else
print ("RESPONSE: " .. event.response)
local data = json.decode(event.response)
if data.result == 200 then
media = data.media_plats
print("Data fetched")
else
print("Something went wrong")
end
end
return true
end
,然后我想在这里访问:
function scene:show(event)
local sceneGroup = self.view
local phase = event.phase
if phase == "will" then
elseif phase == "did" then
-- make JSON call to the remote server
local URL = "http://www.mywebsite.com/temp_files/json.php"
network.request(URL, "GET", loginCallback)
print(data.media_plats) -- returns nil
end
end
在此先感谢。
感谢您的快速响应。正如所说的即将来临的电晕,你能否在第一步中解释我应该做些什么?是的,这正是为什么媒体变量在那里,但即使我从数据删除本地电子邮件无法打印到媒体... – 2015-02-23 17:29:08
@TyTeam看到编辑的代码。希望能帮助到你。 – ryanpattison 2015-02-23 17:52:15
你的代码完美工作。非常感谢你的帮助:D – 2015-02-23 18:07:12