JSON_ENCODE pre php 5.2

Posted May 24th, 2011 in PHP, Web Development by Jonathan

Once again I have run into an issue with one of those big hosting companies. This time it involves running an old version of php, 4.4 to be exact. While this may work for most things if you’re not getting so technical, and I didn’t really think I was, but of course it turns out something I take for granted (running php 5.3 on my production servers) caught me off guard.

I had a simple ajax call for a comment form. Send off the info and send an email out, very simple right. Well if you brush up on your php versions you’ll find that json_encode isn’t available till php version 5.2. So while the ajax call was working, my expected response was not.

So I started searching for a way to mimic the json output to send back, I cam across a post on Stack Overflow that pointed back to the PHP doc’s site on json_encode, and down in the comments boukeversteegh had posted an easy to use function to do exactly what i was looking for.

Continue Reading »

Toolbox – Ajax requests and caching

Posted March 4th, 2010 in Featured, JQuery, Toolbox, Web Development by Jonathan

Today was a reminder of how much I can forget. I have been working on a quick little report to help a group of people here at work. Nothing special, but I was adding some nice functionality to make updating things easier.

Basically each result row had 2 check boxes. Where they could check or uncheck either of them and it would update a table in the background. No biggie I thought, of course I had been developing it in Firefox and Chrome and occasionally in IE 8, and everything previous to the check boxes worked fine in all the browsers.

Continue Reading »

ToolBox – Preloading With Jquery

Posted November 12th, 2009 in Featured, JQuery, Toolbox by Jon

I thought I’d start a new Category called “Toolbox”, specifically for what I use on a daily basis for web development. These are snippets, functions, cheats, etc that anyone can use and make my life as a web developer that much easier…

This installment is something I’ve been using lately to preload images so they don’t spit out the alt text…Mostly it seems to happen when I’m doing something with ajax.

I found this snippet at Matt Farina’s blog.

This is the code (I just made a js file out of it and include it when necessary).

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length;i++) {
      jQuery("<img>").attr("src", arguments[i]);
  }
}

Continue Reading »

Parsing what's dished out (I'm looking at you Godaddy)

Posted October 23rd, 2009 in JQuery, Web Development by Jon

It’s no secret – well if you’ve been listening to me for the past few days, that I’ve been upset with GoDaddy’s free web hosting. I have a side project for a client, and it needed an admin back end done – something to edit the pages, nothing crazy or too difficult and since I love JQuery, I add in some eye candy because it makes it easier to use.

Well as I’m cruising along, certain things that I’m use to doing a certain way just aren’t working. I narrowed down what I thought the problem was and it points right to the stupid ad banner that GoDaddy uses – well more to the point the mechanism they employ to add it to the pages.

It goes as far as attaching to an AJAX request reponse. So when you send your request and you get back a nice little JSON object back, it has some iframe crap stuck to the end of it. It really through me for a loop for awhile. Luckily Scott (and old coworker and friend of mine) got me pointed in the right direction.

Continue Reading »

Jquery Sliding

Posted October 21st, 2009 in Web Development by Jon

The Project

In one of my projects, I thought it would be cool to have a drop down select box trigger a slide down for the results, then slide up and slide back down when a new choice was selected. Seemed pretty easy, but when I got into it, it wasn’t as easy as I thought at first. But in all reality it turned out to be super easy.

I did some digging around to figure out how to tell if my div container (the one that would hold all the results) was visible or not, maybe I should just read the entire JQuery documentation – HA! Instead I turned to google and found that you can check for :hidden.

$("#div-id").is(":hidden");

So I can base my logic on that, if it’s hidden do this or if it’s not do this…

That was perfect, now it was just a matter of having it do exactly what I wanted. So if the div wasn’t hidden, I needed to hide then show it again with the new results. Or if it was hidden, show the results. Continue Reading »