I'm having a problem, I can't make a loop inside this code:
class ProductsPager
constructor: ->
this.waitformsg()
waitformsg: =>
alert 'begin'
$.ajax
type: "GET"
url: "http://0.0.0.0:3000/live/index.json"
async: true
cache: false
timeout: 1000
success: (data) ->
alert data
error: (XMLHttpRequest, textStatus, errorThrown) ->
alert "end"
waitformsg()setTimeout "waitformsg()", 0
The two arlerts are for debugging. It displays me only one time of each: "begin", and right after "end" and nothing else.
I have concluded that the last line is wrong and I need to find a way to call a method inside Ajax.
I have tried to replace setTimeout "waitformsg()", 0
by this.waitformsg()
or even waitformsg()
but it still doesn't work.
I would like to display infinite "alerts" untill the right conditions to succeed are gathered.