I want to add timer to load my JSON file after every 5 sec but i'm getting this error. This is my code for selected category.
function loadFeed(url)
? "Change every 5 sec"
? "URL"url
m.feed_task = CreateObject("roSGNode", "load_feed_task")
m.feed_task.observeField("response", "onFeedResponse")
m.feed_task.url = url
m.feed_task.control = "RUN"
end function
function onFeedResponse(obj)
response = obj.getData()
' turn the JSON string into an Associative Array
fetch = ParseJson(response)
tempStrechData = CreateObject("roArray", 0, true)
m.global.addFields({ strechedData: [] })
if fetch <> invalid and fetch.data <> invalid
' hide the category screen and show content screen
m.category_screen.visible = false
m.content_screen.visible = true
' assign data to content screen
m.content_screen.feed_data = fetch
tempStrechData.Push(fetch)
? tempStrechData
m.global.strechedData = tempStrechData
? m.global.strechedData
else
? "FEED RESPONSE IS EMPTY!"
end if
end function
sub onCategorySelected(obj)
? "onCategorySelected field: "; obj.getField()
? "onCategorySelected data: "; obj.getData()
list = m.category_screen.findNode("category_list")
? "onCategorySelected checkedItem: "; list.checkedItem
? "onCategorySelected selected ContentNode: "; list.content.getChild(obj.getData())
item = list.content.getChild(obj.getData())
m.global.AddField("url", "string", false)
url = item.feed_url
' code for timer
m.testtimer = m.top.findNode("testTimer")
m.testtimer.control = "start"
m.textchange = false
m.testtimer.ObserveField("fire", "loadFeed")
m.top.setFocus(true)
' code for timer
' loadFeed(url)
' loadFeed(item.feed_url)
end sub