XML Literals in JavaScript?

If you’re a web developer and haven’t heard of E4X (EMCAScript for XML), it’s a shame, but you’re likely in the majority. E4X allows you create variables out of well-formed inline XML by introducing an XML object.

Tags:

JavaScript & ASP.NET: Executing on an Event onclick

I’ve been doing a lot of front-end debugging with ASP.NET and JavaScript lately, and one thing has become very apparent: there’s way too many ways to specify that something happens when you click on an link or other element.
First, you could specify what happens when an element is clicked using the classic but naive onclick [...]

Tags:

JavaScript Date Ago

In case you hadn’t noticed, one of the hip things to do with user-visible timestamps these days is to format them as a how long ago the time was. Instead of seeing a date and time like “08/02/2009 2:41 PM PST,” these so-called passed/relative/pretty/friendly dates appear like “2 hours ago” or “1 week ago.”
Being a [...]

Tags: , ,

Fade background color in JavaScript

Background
A project I’ve been working on recently is a light-weight AJAX messageboard that looks a lot like Reddit’s or Hacker News’ comments pages. The spiffy part though is that there’s no refresh needed to see new replies since the page has loaded—new posts aysnchronously appear in the thread as users post them.
To make it obvious [...]

Tags:

JavaScript Query String

Query Strings
When I started coding more client-side JavaScript in replace of ASP.NET code, I was surprised to find there there’s no object in JavaScript that breaks down a query string into a key (or name)/value collection, as this.Request.QueryString does in ASP.NET.
Here’s a URL with a query string:

http://prettycode.com/search?query=code&pageSize=20

The query string is everything that including and [...]

Tags: , , ,

Simplify jQuery with ASP.NET Web Services and JSON

Introduction
In my last post, I gave a quick introduction to using jQuery for JSON communication with ASP.NET web and WCF services. It’s not very complicated, but it’s distinct enough from consuming XML or other services to warrant a little explaining.
In this post, I’m going to suggest you save yourself of writing out or copying/pasting that [...]

Tags: , , , , , , , ,

Using jQuery with ASP.NET Web Services and JSON

By now, hopefully everyone’s played with jQuery for client-side JavaScript work and knows it eliminates the fuss of manually writing Ajax code. In this post, I’ll briefly cover the idiosyncrasies of using jQuery Ajax to consume .NET 3.5 web services that serve JSON. Although I mostly show examples of ASPX pages with WebMethods, all the [...]

Tags: , , , , , , , ,