advAjax tips and tricks
I’ve been fooling around with advAjax (Site is down. Here’s the js file — I’d highly suggest you look into jQuery instead, if you can.) for a few years now. All for simple calls, which the small amount of documentation sufficed. However, the last few weeks I’ve had to use the library a lot more for work. I know it’s rather odd to be using a 3rd party Ajax library like this instead of something like ASP.NET Ajax (Oh…In case you didn’t know I work with asp.net 2.0 all day). I started using ASP.NET Ajax but it was causing a lot of problems with existing JavaScript and other 3rd party controls (Note: This was beta times so who knows if it works now). I also tried ComponentArt Callbacks but found them to be too limited for my needs. So now back to the reason for this blog. I needed to check a value before I would submit an asp.net form. This was a huge headache because, admittedly, I’m not the best at AJAX; I’ve only dabbled. I was having the problem that it was submitting the form THEN returning my AJAX call. After spending hours on this I found that I needed to set my XMLHttpRequest object to be non asynchronous Ajax call.
Great, so now I know what I NEED to do. But how the heck do I do it? I checked the documentation, google, google groups, other people. I turned up with nothing. So I dove into the code and magically it came to me. There is a field called ‘async’ it’s set to true and I needed it false. So simple enough just add that to your call.
As you see below you can modify the methods by adding them to your advAjax call
advAJAX.get({
async : false,
url: ‘../AjaxCallback/Director.aspx’,
parameters : {
“command” : ‘check_initials’,
“initials” : str,
“username” : get_txtUsername().value
}});
List of available (undocumented) fields:
obj.async = true;
obj.mimeType = “text/xml”;
obj.username = null;
obj.password = null;
(I thought the list was going to be longer…should have looked before I started writing
)
Anywho, that’s the long drawn out version of what I’ve figured out.