Jul 28 2008

Missing cookies in jQuery AJAX callbacks?

Tag: Uncategorizedjeremiah @ 3:05 pm

For my current project, we’re making use of a large number of jQuery AJAX callbacks, as well as cookies, to deliver some rich functionality to the users of a web site. Unfortunately this created a little bit of an issue when trying get this to work in IE7.

Here’s what I originally attempted:


function do_something() {
  $.ajax({
    url: 'http://example.com/AjaxRocks',
    type: 'POST',
    dataype: 'json',
    success: success_response
  });
}
function success_response(json) {
  var cookie_data = load_data_from_cookie(); // the implementation of this is not important
  // unfortunately, cookie_data is null so this doesn't really give us the important cookie_data
}

For some reason, the full contents of document.cookie are not available from inside the success_response function call. The solution? Load the cookie’d data before making the AJAX call:


function do_something() {
  var cookie_data = load_data_from_cookie();
  $.ajax({
    url: 'http://example.com/AjaxRocks',
    type: 'POST',
    dataype: 'json',
    success: function(json) {
      success_response(json, cookie_data);
    }
  });
}
function success_response(json, cookie_data) {
  // do something successful
}


Jul 17 2008

IE7, dropdowns, and z-index

Tag: CSS, codejeremiah @ 10:18 am

I spent most of yesterday and most of this morning battling with a IE7 display bug.

Back story: we are using jQuery’s superfish drop down menus (a jQuery based implement of suckerfish/son of suckerfish) for site navigation. Everything works great in Firefox 2/3 and Safari. I’m going to assume that IE6 looks great as well since suckerfish is known to work well in IE6.

IE7 is a different story.

There is a large image directly beneath the navigation menu. Unfortunately for me, in IE7 the menu was being rendered beneath the image, despite having a z-index of 1001.

After some careful (and careless) digging and googling, I came across a solution.

To summarize, IE7 will not render the menu with the appropriate z-index unless that z-index is present on the top level :hover style. To clarify:


/*** ESSENTIAL STYLES ***/
.sf-menu, .sf-menu * {
margin: 0;
padding: 0;
list-style: none;
}
.sf-menu {
line-height: 1.0;
}
.sf-menu ul {
position: absolute;
top: -999em;
}
.sf-menu li:hover {
z-index: 100; /* This is the important style directive, without it IE7 chokes */
}
.sf-menu * li:hover {
visibility: inherit; /* fixes IE7 'sticky bug' */
font-weight: bold;
}

IE7 Suckerfish Hover CSS


Jul 15 2008

Who needs valid XML?

Tag: TFS, Visual Studiojeremiah @ 10:32 am

Team Foundation Server, apparently.

Let’s say that some careless developer (me) forgot to close an XML tag. The aforementioned developer then checked in his build file and attempted to build it.

At this point, I got a bit worried because TFS came back with the following error:

TF42046: The build service used in the build process is not reachable. This error occurs when either the build machine is off-line,the required service is not running, Team Build is not installed on the build machine, Team Build is configured for a different Team Foundation Server or the network is not available.

So, at this point I spent a few minutes attempting to debug this problem. It turns out that this problem can also be caused by silly developers leaving off closing XML tags in their hurry to finish the weekly build script.

Why would Visual Studio throw back this seemingly unhelpful message? Probably because my XML was garbage and TFS simply refused to talk to me on the grounds that I am uncouth and trying to shout the XML equivalent of dirty words at it.

Moral of the story: close your XML tags and don’t hurry.

[edit]
Rick has informed me that I am a horrible developer and forgot to mention his involvement in this whole issue. So, Rick, thanks for helping me troubleshoot this problem. Read his blog, it’s at RickDoes.net. Did you notice that URL? He’s witty, much wittier than I.


Jul 11 2008

SQL Server 2008 Installation Features

Tag: SQL Server, sqljeremiah @ 6:26 am

Eric Johnson has put up a fantastic post detailing the new SQL Server 2008 Installation Wizard or, as it is officially named, SQL Server Installation Center.

Rather than summarize, I’ve just provided a link. It’s short, sweet, to the point, and full of screen shots.


Jul 05 2008

Software Development Meme

Tag: code, nonsensejeremiah @ 9:49 pm

Rick, I’m stealing your post. Which is okay because you stole it first.

How old were you when you started programming?
I originally started learning BASIC when I was very young, probably 11 or so. I gave up on programming for more worldly pursuits, only to come back to it 10 years later.

How did you get started in programming?
The second time around I wanted to create a ‘blog’, although at the time I don’t think we called them blogs. I think we called them e/n sites (everything/nothing). So I taught myself HTML.

What was your first language?
HTML, CSS, and Perl. It was a triple whammy.

What was the first real program you wrote?
The first real business program I wrote was a socket server written in PERL that accepted a rudimentary home grown protocol. It was used to remotely monitor the health of 8 different servers. What can I say, I started out as an HP-UX sysadmin.

What languages have you used since you started programming?
HTML, CSS, JavaScript, C#, VB.NET, ASP.NET, PERL, Python, Ruby, SQL (T-SQL, PL/SQL, PL/PGSQL), PowerShell, BASH scripts, SVG, XPath, XQuery, XSLT, ActionScript. Jack of all trades, master of none.

What was your first professional programming gig?
I worked at Qwest Communications writing unimpressive PERL scripts to automate keeping an Actuate Reporting Server running without too many memory leaks. I graduated to doing the same thing for Local Number Portability software. If you don’t know what LNP is, just think of it this way: it’s the reason your calls go through and the reason you can change carriers and keep the same number.

If you knew then what you know now, would you have started programming?
I might have kept with it when I was younger. Although, frankly, I think a good part of my approach and expertise come from my lack of formal training and my background in the Humanities. Getting a four year degree in CS would have probably proved impossible for me. However, that BA in English has taught me a great deal about the importance of communication, documentation, and solid presentational skills.

If there is one thing you learned along the way that you would tell new developers, what would it be?
Communication is key. This stretches across every aspect of what we do on a daily basis. If you can’t communicate your ideas clearly and succinctly, the boss is never going to push for your pet project. If you can’t describe a problem well to non-technical people, they will never understand the importance of the issue. If you can’t share your failures and successes with fellow developers, someone will end up repeating your mistakes. Communicating is how we all learn. If people didn’t feel the urge to share their knowledge and write books, we would still be building Altair clones in our basements from Radio Shack kits.

What’s the most fun you’ve ever had … programming?
Frankly, every day is fun. I get to share knowledge with some exceptionally talented developers and I’m always learning from them. The best times are when I get to work with a dynamic team of people and build on each others ideas to make the best software we can.


Next Page »