Hi all,
Firstly I am no code guru. I came from an ASP scripting background and I am slowly getting my head around proper OOP using c# .net and javascript, so be patient!
People are expecting more and more that their shiny new website backends do lots of things without the page refreshing, and why not.
I have one particular page where there are about 10-15 actions which result in an ajax call and some update on the page.
Right now I am creating lots of individual ajax calls like this (sometimes using delegation as elements are squirted in and out);
$('element').addEvent('click', function(event){
event.stop (prevent default whatever is needed)
create request object
feed in the url
feed in the post data
create an oncomplete function
do whatever needs doing to the page
send request
});
This feels inefficient and there is lots of code reuse, but when I thought about abstracting some of it away into a custom class my knowledge fled and I couldnt think up anything much more efficient.
If I made a class it would have to receive the url, a post data object, and a callback function to jump to after it had completed..which means I'd still be typing out most of what I already do.
I imagine this is not an uncommon scenario and was wondering how the wizards handle lots of ajax calls on the same page, all of which may have subtly different behaviours.
Thanks
Rolf