More jQuery Fun – Auto Populating a Select Box
Problem: You want to dynamically populate a select box and you don’t know how.
Solution: Easy, I will show you.
First off, I lied there is no built in way in jQuery (why?, I don’t know) to automatically populate a select box. But it actually is very easy. There are plenty of methods to accomplish this but I like to do it this was because utilizes the Option object and it doesn’t require html string concatenation.
The basics
Example 1:
Here is the code for the onlick event of that button: › Continue reading
Fun with jQuery – toggle() – Easy tips to visually enhance your website
Here’s a quick tip to add some cool effects with jQuery that require very little code to implement. In this example I’m going to so how use of the toggle function can make the simplest functionality and jazz it up.
.toggle()
In a nutshell, the toggle function will call the show() function if your element isn’t visible and the hide() function if it is.
- Hamburger
- Philly Cheese Steak
- Taco
- Pizza
- Something else greasy and unhealthy
<br /> <input onclick="$(‘#preview1′).toggle();" type="button" value="Toggle My Menu" /><br />
So as expected, clicking the button will toggle the menu. Now lets get a little more flashy:
› Continue reading
Hiding Unnecessary Response Headers Apache/PHP
One way to help protect your website/server is to not tell everyone what platform and app versions everything is running on. If you were to request a php file from my site you see some response headers that could be useful to people looking to break in, cause havoc etc…
Here is my request to aknosis.com (I’m viewing all of this in Firebug, if you don’t have it get it, best web development tool in my arsenal)
| Date | Wed, 14 Oct 2009 05:59:59 GMT |
| Server | Apache/2.2.3 (CentOS) PHP/5.2.9 mod_ssl/2.2.3 OpenSSL/0.9.8b |
| X-Powered-By | PHP/5.2.9 |
| X-Pingback | http://www.aknosis.com/akwp/xmlrpc.php |
| Expires | Wed, 11 Jan 1984 05:00:00 GMT |
| Last-Modified | Wed, 14 Oct 2009 06:00:00 GMT |
| Cache-Control | no-cache, must-revalidate, max-age=0 |
| Pragma | no-cache |
| Vary | Accept-Encoding,User-Agent |
| Content-Encoding | gzip |
| Content-Length | 10636 |
| Keep-Alive | timeout=2, max=100 |
| Connection | Keep-Alive |
| Content-Type | text/html; charset=UTF-8 |
So if I was running a known insecure version of php, apache, or any other out of date software exposed in the response headers, an attacker has to look no further to determine what you are using and how best to attack you.
Apache
Optimizing Website Peformance with a CDN (jQuery)
If you want to increase load times for your site a good way is to serve your resources (js/images/css) from different hosts. Even better is to use a CDN (Content Delivery Network) that has edge locations, see Amazon’s CloudFront, that will serve those resources from hosts that are nearest to your viewers. If it is logistcally possibly for your needs and its free is there any reason not to? Yes.
Specifically if you use jQuery on any of your sites more than likely you serve it with every page on your site, so if you want to have one less request for every page just use a free CDN to host it: Google / Microsoft
A recent blog post @ elijahmanor.com explains more why you would want to do such a thing. However, a commenter on that blog post has a good point… If I point my jquery resource at one of these cdn’s how do I know that the files are being served since it is all client side? What’s worse is how much functionality is broken if jquery is 404′d from that CDN?
Well here’s a little trick that you can use verify that jQuery is loaded and how to handle it if not:
Testing Plugin Syntax Highlter Evolved
Just a quick post to test the Syntax Highlighter Evolved plugin.
<br />
<?php<br />
$this = ‘only a test’; //ignore me<br />
$shout = new shoutOut();<br />
try {<br />
$shout->out();<br />
} catch (Noise $n) {<br />
$shout->whisper();<br />
}<br />
Make any webpage printer friendly and create pdf’s on the fly
I just noticed this was added to my sociable plugin, but I have to say it is definitely a great concept and it is one of those things that makes you wonder why it took so long to come about. I would use this any day over some browser plugin, the less crap to fill up my browser that it wasn’t intended for the better. The coolest part is being able to remove any content in the url and print your modified version of the page.
Just downloaded Pandora for my…
Just downloaded Pandora for my BlackBerry. All I can say is wow!
Google Ads
Tags
Categories
- Hardware (1)
- Information Security (2)
- Scams (1)
- Programming (13)
- JavaScript (7)
- jQuery (4)
- MySQL (2)
- php (3)
- JavaScript (7)
- Quick Tips (8)
- Ramblings (30)
- System Administration (4)
Recent Posts
Recent Comments
- Aknosis on Automating MySQL Database Backups on the Command Line via mysqldump
- brittany on Automating MySQL Database Backups on the Command Line via mysqldump
- Aknosis on More jQuery Fun – Auto Populating a Select Box
- zkilz on More jQuery Fun – Auto Populating a Select Box
- Aknosis on More jQuery Fun – Auto Populating a Select Box