| Subcribe via RSS

WordPress Replacing Ampersands in Javascript

August 19th, 2009 | Comments Off | Posted in Javascript, WordPress

As great as WordPress is for running a blog, it comes with more than its fair share of headaches for the developers out there. Today, I was putting some javascript code into the body of my post. Whenever you get more clever than basic text and html in the body of a post, watch out! So WordPress started chewing up all my ampersands and replacing them with & and of course the javascript was rendered useless. I searched high and low for a fix and nothing. I know there has to be a config file somewhere in this WordPress install that replaces those ampersands. I’m sure its for XHTML compliance issue or something like that, but I want to be able to rid myself of this intrusion. So while I didn’t find a solution, I did find a work around that should have occured to me earlier — just wrap the javascript up in its own file and make a reference to it from the post body. It would look something like this:

The key here is, if WordPress can’t process the javascript directly, it can’t mangle your ampersands. F%$kin’ A man!

Tags: ,

WordPress Running Slow on GoDaddy

August 18th, 2009 | 1 Comment | Posted in goDaddy, Javascript, WordPress

I don’t know what it is, but for the past week all my blogs have been running dog slow on GoDaddy. All my other sites (ASP.NET based) run fine. I contacted support and I got the ever so unhelpful “this problem is something on your side” or my personal favorite “you need to upgrade your account to a dedicated server.” What? You can’t support a measly blog, and you want me to shell out major bucks for a dedicated server? Not happening. After doing some investigation on the web, nothing could be further from the truth. Many, many, many people are having these slow crawling load times when running WordPress on GoDaddy. The solution — find another web host. Seriously, out of the four web forums I scoured no one had run across a solution past jumping ship.

The one host that kept coming up time and again in my research was Bluehost. Even WordPress themselves had Bluehost listed first on their list of recommended web hosts. Everyone kept saying their support was great and load times were very quick. I just got setup yesterday with them, and I’m busy pulling over files and setting up databases. I’ll check back in to let you know how it goes.

Update [8/27/09]: One week on BlueHost, and I’m happy to confirm that all blogs are zipping right along. No delays, no unbearable load times, none of that Godaddy crap. The problem definitely wasn’t on my end. You’d think they’d be able to at least run a little WordPress blog. Guess I expect too much. As far as the transition over to BlueHost, it was fairly painless. Basically, you just export your mySQL database to a file comprised of a bunch of SQL statements. After creating the cooresponding database on your BlueHost mySQL account, you just import the SQL file and all your data is up. Then just download all your blog files and restore them to the new folder location you’ve setup for the site on BlueHost. Next you need to point the wp-config.php file to the new database as follows:

Your final step is just to go into your domain provider and point the DNS record to go to BlueHost. The DNS servers you are looking for are primary NS1.BLUEHOST.COM and backup NS2.BLUEHOST.COM. Then you just have to wait for the changes to propogate through the Internet’s hub routers. I’ve seen it take as quick as five minute to a couple of hours. No rhyme or reason to it. Whalah you’re setup and you’ve left Godaddy’s interminable crawl in the past.

Oh with regards to support, BlueHost was very responsive. I submitted 4 requests as I was getting setup and they were normally back to me within 30 minutes to an hour via email, and I didn’t get a single boneheaded answer that was cut and pasted out of the knowledgebase that had absolutely nothing to do with my issue. Of course that was the norm with Godaddy’s hosting support and many other hosts I’ve used in the past. Very satisfied so far with the whole hosting experience at BlueHost.

Tags: , ,

Opening a Popup Window from a Link via Javascript

July 20th, 2009 | Comments Off | Posted in Javascript

Fairly simple task today. I’m just looking to open a popup window using javascript. There are several different ways and complexities on how to approach this, but I found this the easiest. First, we define our window.open function in our page header section. Next, we pass in the parameters we want to set for this new window — namely the page we want to open, an identifier for that page, and a slew of properties like menubars, height, width, etc.

Now that we have all that established, its time to call the javascript function from our page. In the following we are wrapping up an image in this hyperlink for the popup. Setting the href to javascript:win1 makes our call and triggers the popup window. Simple as can be.

Storing State in AJAX/Javascript: Cookie Based

February 23rd, 2009 | Comments Off | Posted in AJAX, Javascript

In searching for the best way to persist state in my AJAX application, I found writing to a cookie to be the best alternative. The following is an example on how to implement cookie based state management in javascript/AJAX:

Reference Article: http://www.w3schools.com/JS/js_cookies.asp

Tags: , ,