Ajax battle rejoined - won!
Posted on January 5, 2006
2 Comments
I got to work this morning pretty damned humble. I was still stumped by my embarassing lack of "ajaxness" and not quite sure what to try next. But, after two Mountain Dews, I had a plan. Build a very very simple test client and experiment. Ok, truly a hacker's plan, but oh well. I like to "experiment."
All this is in a classic ASP environment, btw.
First, I built what seemed like a lean and mean client page. No database interface, just the necessary javascript and the bare minimum of html. In fact, just enough html to display one lonely checkbox (in a wellformed way, of course).
Next, I added a spot of code to my server side code. Using an existing table, I stuffed in a boolean value for a pre-set row. All this function had to do was fetch that boolean, flip it and update it. True becomes false. False becomes true.
Things started rough. I no longer was getting the weird error from yesterday (thankfully!) but... well, here's the deal: Against my IIS 6 server, it worked in IE, but still returned the 411 in Firefox. However, against my IIS 5 server Firefox worked. And just to be interesting, IE returned the 200 (OK) but... truly failed -- no database update. I was pulling out hair.
Being the modern coder that I can be, I did the obvious: head to Google (and groups.google.com, of course!). Didn't find anything compelling about ajax and different versions of IIS. Decided to just search up some tutorials and try to find an example similar to what I wanted to do. Frankly, didn't find much, but... found one (at mozilla.org no less) that showed some "extra" lines of code that none of the others I'd looked at were showing. *eureka*
Note that if you want to POST data, you have to change the MIME type of the request using the following line:
JavaScript:
http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
Golly. That pretty much sums it up. I do indeed want to POST. Most of the tutorials and samples I was looking at were all about the GET. But oh no, that's not my style. I'm a poster, not a getter. Or something... Anyways, that was the final piece I needed. I won't deny I'd made other changes along the way... but that's the guy that got me working.
Took what I learned there, applied it to my real-world scenario and knocked it out 15 minutes later. Even added some fancy-schmancy div tag filling on the fly for status updates - with fading javascript no less!
Yep, I'm cocky now. Beware.
Tags: ajax, IIS, programming
Possibly Related Posts
Comments
2 Responses to “Ajax battle rejoined - won!”
Leave a Reply



You just solved my bug! Thanks for taking the time to do a writeup on this problem.