Visual Basic .NET » Web Forms
First page load and caching -- Siberwulf --


I've been working on a project using AJAXPro.2 and .NET 2.0.

Essentially, every time I come to the page for the first time, my call to ajax returns 'null' (I get errors when I check it using typeof( ).
However, when i hit refresh, everything performs nominally.

Another oddity: I've put the AJAX call in a setInterval format, so it executes every 5 seconds. However, on the first time to the page, it will poll every 5 seconds, and still not return anything that can be compared using typeof( ).

Any help is appreciated. I'm using AJAXPro.2.dll v6.7.11.1

Thanks!

-- MichaelSchwarz --


Hi,

one big mistake is the use of setInterval because Ajax requests should run asynchronous and a call can run longer as your timer. Please change this to setTimeout and call another setTimeout in the callback:
function callback(res) {
// do your work here
// and then call the setTimeout
setTimeout(invoke, 1000);
}

function invoke() {
Namespace.Class.MyMethod(1, 2, 3, 4, callback);
}
This example will call MyMethod nearly every second (1000 msec).

Regards,
Michael

On 7/17/06, Siberwulf <Siberwulf> wrote:

I've been working on a project using AJAXPro.2 and .NET 2.0.

Essentially, every time I come to the page for the first time, my call
to ajax returns 'null' (I get errors when I check it using typeof( ).
However, when i hit refresh, everything performs nominally.

Another oddity: I've put the AJAX call in a setInterval format, so it
executes every 5 seconds. However, on the first time to the page, it
will poll every 5 seconds, and still not return anything that can be
compared using typeof( ).

Any help is appreciated. I'm using AJAXPro.2.dll v6.7.11.1

Thanks!
>

--  

Best regards | Schöne Grüße Michael

Microsoft MVP - Most Valuable Professional Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz 
/
http://www.schwarz-interactive.de 
/
mailto:info
-- Siberwulf --


Michael,

Thanks for the reply. However, I don't believe that solution will work. Right now, my page has about 15 controls that are polling for data to display (call it a ueber chat room). The issue we previously had was that calls were stepping on each other, due to the frequency in which they were polling for data. I devised a pipeline of sorts, where only one control at a time could have access to calling their own ajax method at one time. This worked, but as you can see there are some kinks. In your model above, as soon as I got denied access to the pipe, the loop would stop.

Might you have some alternative ideas?

thanks again in advance.

-- MichaelSchwarz --


What do you mean with "as I got denied access to the pipe"? AjaxPro will every time call the callback or onTimeout handler.

Regards,
Michael

On 7/18/06, Siberwulf <Siberwulf> wrote:

Michael,

Thanks for the reply. However, I don't believe that solution will
work. Right now, my page has about 15 controls that are polling for
data to display (call it a ueber chat room). The issue we previously
had was that calls were stepping on each other, due to the frequency in
which they were polling for data. I devised a pipeline of sorts, where
only one control at a time could have access to calling their own ajax
method at one time. This worked, but as you can see there are some
kinks. In your model above, as soon as I got denied access to the
pipe, the loop would stop.

Might you have some alternative ideas?

thanks again in advance.
>

--  

Best regards | Schöne Grüße Michael

Microsoft MVP - Most Valuable Professional Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz 
/
http://www.schwarz-interactive.de 
/
mailto:info
-- Siberwulf --


(to clarify, this is very similar to the lock() command in C#.-

-- Siberwulf --


Basically, I created a pipe system. It contains a var that says who is using the pipe and how long they've had it.

When a control wants to execute its ajax method, it checks to see if the pipe isn't in use. If the pipe is in use, the method will try again after its next setInterval(). If the pipe isn't in use, the control will claim it, set it as "in use" and then do its function.
When the function is done (asynch or synch, it doesn't matter), then the control will mark the pipe as open again.

This was setup, becuase 15 controls executing at the same time was causing issues where each could and would step on the other.

[Submit Comment]Home