Textbox typing lag when accessing AJAX method

J

JM

Hi,

I transferred an AJAX application to the server to be used across the
Internet. On my localhost, it works great. But when I transferred it to
the server, the user control freezes for a second or two whenever it
calls the AJAX method, including the textbox where the user inputs the
chat message. All it does is retrieve new messages from the server
every second. Please help if you have any idea to how to make the
textbox run smoothly, without lag when the user types.

Thanks
 
J

Josh Mitts

Are you using asynchronous calls, passing along an OnComplete and OnTimeout
method?
 
J

JM

Nope, I don't use OnComplete and OnTimeout. Any suggestion how I can fix
this problem? Thanks!!
 
J

JM G

Nope, I don't use OnComplete and OnTimeout. Any suggestion on how I can
fix this problem? Thanks!!!
 
J

JM

Nope, I don't use OnComplete and OnTimeout. Any suggestion on how I can
fix this problem? Thanks!!!
 
J

Joshua Mitts

Check out this page, it has an explanation of how to use OnComplete and
OnTimeout:

http://atlas.asp.net/quickstart/atlas/doc/services/default.aspx#simple

The idea is that you need to wait for the reply from the server in a
seperate thread (asynchronous), and using OnComplete and OnTimeout makes
that possible.

Also, I would look at your architecture...if you are building chat, you may
want to think about another design besides checking for new messages every
second. It may be the only way, especially if you want cross-browser
compatibility, but...something like a rich client control or ActiveX may
accomplish the job a lot easier, since they can use a dedicated socket
connection to get data from the server instantly.
 
S

sp3d2orbit

AJAX.NET allows you to do asynchronous calls. If your call looks
something like this

var res = PageName.MethodName(param1, param2)

then you can make the same call asynchronous:

function MethodNameCallBack(res)
{
//do stuff
}

PageName.MethodName(param1, param2, MethodNameCallBack)

This will allow your page to load while waiting for the information
from the server. Also, if you're doing a lot of AJAX during a page load
you're obviously going to have a latency since each requires a trip to
the server. Try to initially load the page with as much information as
possible and limit AJAX calls to updates.

Best of luck,

Matt Furnari
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top