Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Monday, January 12, 2009

Don't take shortcuts on script tags!

This problem annoyed me for longer than I would have hoped recently - even though I have seen it before and spent a frustrating time 'fixing' it. I added a script reference (the first for the page) to the head of a html page and lazily wrote it as

<script type="text/javascript" src="scripts/jquery-1.3.1.js" />

Well this broke the ScriptManager, which couldn't hook up the postback methods for the UpdatePanels on the form. Hmm that's odd, even an empty .js file included this way cause a javascript error on page load such as "this._form is null" or "__doPostBack is not defined". And then something twigged from a not-so-distant project and there it was

<script type="text/javascript" src="scripts/jquery-1.3.1.js"></script>

Lesson: Don't take shortcuts when writing script tags!

More explanation of why http://ajaxian.com/archives/why-doesnt-script-work

kick it on DotNetKicks.com Shout it

Thursday, June 08, 2006

Quirks of the XmlHttp object

As useful as the XmlHttp object is, it also has its quirks. They really only show up though if you don't treat it nicely. Here is a list of some quirks http://www.quirksmode.org/blog/archives/2005/09/xmlhttp_notes_r.html
 
One interesting and very useful part of XmlHttp is the responseXml field. This field is an XML DOM object that is automatically populated if the content returned from the Http request is "text/xml". Very cool! I have found it is also faster than creating your own XmlDom object and then loading the Xml.

kick it on DotNetKicks.com Shout it

The XmlHttp object

A while ago I was wanting to find out a bit more about the XmlHttp object for JavaScript. This page provides a nice introduction to using the XmlHttp object to provide rich web interfaces.
 

kick it on DotNetKicks.com Shout it