SACK 1.6
…and I’m back.
After around 3 weeks of nothing, I can only apologise - as real life and work has been meaning the last thing I have been able to do is take care of this corner of the web. My poor delapidated website! I must look after you more (and finish the redesign).
It’s that time again, an updated version of the Simple AJAX Code Kit.
This time however you can thank Matthew Turland for generally being awesome and adding in the latest batch of changes. Matthew and I discussed some ideas for SACK over IM and we came up with some really neat additions. He was then cool enough to add them in himself and send them to me. I should have released this miles earlier, but aforesaid real life stuff got in the way.
Sorry about that.
After checking it over it’s now ready to release, so what’s new with SACK? Well…
- New option: queryStringSeparator, which defaults to “?” - most of you won’t need to change this, but someone might, so may as well make it simple to do eh?
- New option: argumentSeparator, which defaults to “&” - again, most of you won’t need or want to change this, but you might.
- new method - onError, a function that is called when the status code of the response isn’t 200 - something has probably gone wrong with the request.
- new method - onFail, the most significant change. Now, instead of the failedalert message (which most people seem to be turning off anyhow), the code will run this function if AJAX isn’t supported by the browser. This puts the reaction firmly in your control - you could use other methods, or maybe even just redirect to a version that supports older browsers. Anything really - it’s up to you.
- Plus Matthew tweaked some of the string parsing I was doing to use regular expressions, which is great as I’d always wanted that but never really bothered with it (regular logic worked and was easier to test with when I wrote it). In theory this should make SACK slightly faster, though I’m not sure if it will be noticable.
Anyhow, please let me know what you think: is it good? How can it be better? Found a bug? Got a feature idea? All of the above can be sorted with a simple comment here on this post!
Go to the main SACK page and get the new version which is, as ever, completely compatible with the old one.
edit - a small bug in formatting the urlstring when one has already been passed to the library was pointed out to me, and I have updated the library to reflect that. This version is 1.6.1.
on March 16th, 2006 at 22:46
I had problems getting SACK to work and I fought with it for hours. As it turns out, the problem was I was passing the form method (straight from the form.method property itself)… and it wasn’t being recognized because the form method was in lowercase.
To account for this I updated tw-sack.js to convert the method to uppercase everywhere the method is referenced.
CHANGE LOG
* On lines 132, 134, & 136 I
changed: this.method –> this.method.toUpperCase()
I am putting together a presentation for my office’s monthly “Tech Share” to demonstrate AJAX at my marketing/web development firm and your code will greatly simplify the source code used in this presentation!
Thanks!
on March 17th, 2006 at 11:52
Good point, I’ve also got to change the toLowerCase assignment in SACK. I’ll make those changes and update to 1.6.2
on May 30th, 2006 at 22:13
I have a question about passing form data.
Let’s say I have a form and a “submit” button. The button calls the doit function which does all of the sack setup and running. Per the documentation, it says that the recommended way of passing form data is to create a sack variable for each form variable. This is somewhat of a large task if the form is huge. How do I pass the entire form data through sack to the php script rather than creating and setting each variable in the “doit” function.
Thanks!