“everyone gets to make one big mistake. and if your waiting on me well i guess your gonna have to wait. cus im saving mine up for a very very special day. when i can fuck it all up in the most spectacular way.”
“everyone gets to make one big mistake. and if your waiting on me well i guess your gonna have to wait. cus im saving mine up for a very very special day. when i can fuck it all up in the most spectacular way.”
I’ll be honest, I thought this was going to be a 5 minute job to a add nice be of autocompleteness to a project. However, if the requirement to pass 3 parameters as your data array (id, value, label) was in the documentation, I missed it.
The JSON, should look like this;
{"response":"true","message":[{"value":"CSS3","label":"CSS3","id":"3"},{"value":"Slider","label":"Slider","id":"4"},{"value":"PSD","label":"PSD","id":"5"},{"value":"CSS","label":"CSS","id":"7"}]}
I was using CodeIngiter, so my controller looks like this (ignoring the DB selects which should be moved to a model). Also, ensure that you output the correct headers (application/json), otherwise you’ll just be setting yourself up for a whole load of new, difficult to spot problems;
function get_tags_as_json()
{
$tag = $_REQUEST['term']; //get term parameter sent via text field.
$this->db->select('*');
$this->db->from('tags');
$this->db->like('tag', $tag);
$this->db->limit('5');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
$data['response'] = 'true';
$data['message'] = array();
foreach ($query->result() as $row)
{
$data['message'][] = array(
'value' => $row->tag,
'label' => $row->tag,
'id' => $row->id
);
}
}
else
{
$data['response'] = 'false';
}
header("Content-type: application/json");
echo json_encode($data);
}
and then my jQuery;
$(function() {
$( "#tags" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "http://linkspro.dev/admin/get_tags_as_json",
dataType: "json",
data: request,
success: function(data){
if(data.response == 'true') {
response(data.message);
}
}
});
},
minLength: 1
});
});
I’ve been using Tank Auth for a few CodeIgniter projects recently which, if you haven’t checked out, is a great way to get started quickly and securely with some simple user authentication.
For my future reference as much as anything else, I was having some problems with it quite randomly logging me out, and after a lot of digging I arrived at pining the blame on my use of the Google jQuery CDN. Not entirely sure why that is causing the problem, but since removing it, so far so good.
Hopefully I will post back with a bit more info once I’ve had time to dig further.
Last week, I resigned from my job. Not an easy thing to do when your best friend lectures you about the recession and the fact that you haven’t actually got anything at all lined up.
However, I’m firm believer in just having a good bit of faith in myself, and that generally, when needed to and when either jumping or stepping into the abyss, it’s worth remembering that it only ever comes up to your knees.
So what am I to do now? I’m a web developer. In fact, to describe myself as just a web developer really doesn’t do justice to what it is I’m good at.
I’m at my best working across disciplines, directly with customers and businesses who not only require sound web design and development, but also need advice about how people might use and engage with their products. I like to think that I might change the way people will do business, and show them better ways to realise their ideas.
In recent years, I’ve helped bring a small design agency into the world of digital design and development, and seen that company grow so invaluable to it’s clients, that it was acquired by one.
Before that, I had the good fortune to blend work and pleasure by helping to found a unique music industry startup – from the heady days of planning it in the pub, the UI planning and design, and finding and working with a small team of talented Rails developers – this was the most fun you could have in a rented loft.
I’ve managed development teams – both my native PHP fellows, and also Rails developers. I’m also perfectly happy and resourceful enough to work on my own – knowing enough to bring a project to life from scoping, through to deployment.
I’ve built and managed e-commerce sites, price comparison services, download stores, blogs and much more.
Most good things start over coffee or a pint, so if I sound like someone you’d like to work with, then please get in touch.
Whilst tidying up some files on the MacBook, I started going through some old People’s Music Store stuff that I had saved for posterity. People’s Music Store was a digital music download service with a difference. We charged the users with creating the store fronts, picking the stock, reviewing the music, and selling it in their own customisable store front. In another universe, I am certain it toppled iTunes from up on it’s sterile, transparent roost.
Anyway, for our launch, we rewarded every early adopter who was willing to share their postal address with a welcome package. We gave them art, sweets, poetry, stickers, and some photographic inspiration. I was in charge of the FujiFilm Instamax (yeah – doesn’t quite have the same ring to it as “polariod”).
These are actual scans of the highly prized shots that made it into the welcome packages. Probably worth thousands now I’m famous…
Quite honestly, there wasn’t much in it. I’d like to think that I have more to say than I can fit on one line, and I’d like to think that I have a bigger attention span than twitter seems to want to impose on me. Every time I try and keep up with it, I end up feeling like I’ve gorged on too much internet.
So I installed WordPress (which, as a developer, makes me feel like I’ve gorged on yesterdays’ dominos pizza, and will likely wake up with a slice attached to my face. But that’s another post).