The setInterval() function can take a string (which is "evals") or a
"reference" to a function (which is the recommended way).

To invoke a function via setInterval/setTimeout with arguments what is
usually done to use an anonymous function/closure.

So something like:

slideshow_interval = setInterval(
  function() {
    PageMethod("getNextSlideShowItem", ["elmID", callerID,
"CampaignID", hdnCampaignID], onSuccess, onFail);
  ),
1000);

On a side note: I wouldn't recommend loading via ajax at such a small
interval (1 second). In the "real world" the response will frequently
end up taking more than 1 second to return from the server.

Karl Rudd

On Mon, Nov 24, 2008 at 7:07 AM, Sean <[EMAIL PROTECTED]> wrote:
>
> HI There,
>
> I'm trying to call a method using the setInterval function that call
> has some parameters but I can't get it to work. Can someone give me a
> hand with the syntax please.
>
> Sean
>
> slideshow_interval = setInterval( 'PageMethod("getNextSlideShowItem",
> ["elmID", callerID, "CampaignID", hdnCampaignID], onSuccess, onFail)' ,
> 1000);
>
>
> function PageMethod(fn, paramArray, onSuccess, onFail)
>  {
>
>   var pagePath = window.location.pathname;
>   var paramList = '';
>   if (paramArray.length > 0)
>   {
>     for (var i=0; i<paramArray.length; i+=2)
>     {
>       if (paramList.length > 0) paramList += ',';
>       paramList += '"' + paramArray[i] + '":"' + paramArray[i+1] +
> '"';
>     }
>   }
>   paramList = '{' + paramList + '}';
>
>    $.ajax({
>        type: "POST",
>      //  url: "WebForm8.aspx/getNextSlideShowItem",
>        url: pagePath + "/" + fn,
>        data: paramList,
>        contentType: "application/json; charset=utf-8",
>        dataType: "json",
>        success: onSuccess,
>        fail: onFail
>    });
>    }
>  });
>

Reply via email to