Read the latest web development and design tips at Fred Wu's new blog! :-)
Poke me on GitHub

Posts Tagged ‘AJAX’

Release: [jQuery Plugin] Endless Scroll

Latest release: v1.4.1

If you don’t already know, endless scroll (or infinite scrolling) is a popular technique among web 2.0 sites such as Google Reader and Live Image Search, where instead of paging through items using the traditional pagination technique, the page just keeps loading with new items attached to the end.

I have developed a jQuery plugin to easily achieve this.

Requirement: jQuery 1.2+

The plugin is tested with jQuery 1.2.6, 1.3 and 1.4.

There are a few options to customise the behaviour of this plugin:

  • bottomPixels (integer) – the number of pixels from the bottom of the page that triggers the event
  • fireOnce (boolean) – only fire once until the execution of the current event is completed
  • fireDelay (integer) – delay the subsequent firing, in milliseconds. 0 or false to disable delay.
  • loader (string) – HTML loader
  • data (string) – plain HTML data
  • insertAfter (string) – jQuery selector syntax: where to put the loader as well as the plain HTML data
  • callback (function) – callback function, accepets one argument: fire sequence (the number of times the event triggered during the current page session)
  • resetCounter (function) – resets the fire sequence counter if the function returns true, this function could also perform hook actions since it is applied at the start of the event

(more…)

Related posts

jQuery problems in IE? It could be SWFObjects.

So your jQuery/JavaScript code doesn’t have any errors, yet your site isn’t working as expected in Internet Explorer? It could be that you have some SWFObject code interfering with your jQuery code (if for example, you’re using a Flash video player or something along those lines). The solution is very simple. Simply enclose your SWFObject code in a jQuery $(document).ready() as so:

<script type="text/javascript">
    $(document).ready(function(){
        var so = new SWFObject("movie.swf", "mymovie", "400", "100%", "8", "#336699");
        so.addParam("quality", "low");
        so.addParam("wmode", "transparent");
        so.addParam("salign", "t");
        so.write("flashcontent");
    });
</script>

The only downside to this is that if you have some alternate HTML to show when Flash isn’t present, this text will be shown until the document is fully loaded and the player(s) start to render (even if the user does in fact have Flash installed).

Related posts

json_encode() for PHP4 and early PHP5

Had a beauty today. There I was ready to deploy some nicely polished code to the server. After some thorough local testing it looked like it’d be a smooth process. So the code went up, but all my funky AJAX stuff stopped working on the server. How could that be? It was perfect locally… :)

It took a little while but in the end I realised what was going on – json_encode wasn’t working. The server was running PHP 5.1.6 and json_encode only became “standard” with PHP 5.2.0 onward.

I needed a solution fast. No time to recompile a newer version of PHP, add libraries or anything fancy like that. I just needed the function json_encode to work right now. Thankfully, the solution was as easy as adding replacement a function a user kindly submitted from the PHP site itself:

http://au.php.net/manual/en/function.json-encode.php#82904

I blindly assumed PHP 5 was PHP 5. I wasn’t using any extremely fancy commands or anything, but I still came unstuck. So the moral of today is check your server specification right down to every last decimal point! ;)

Related posts

Oh, where did my theme go?

Ever since the word ‘blog’ has been invented (or discovered) I have played many different solutions, WordPress has always been my favourite. My old sites run on it, and my new site (what you are currently seeing) run on it.

I had a very tiring day, actually it’s a two-day roll. I’ve been completely sucked into making the theme working, and as a result of that I did not sleep at all last night. Fortunately the website is now up and running, all the basic stuff are done so in the upcoming few days I will be doing more adjustments and tweaks.

A few moments ago I took a quick nap, and I woke up seeing my theme was gone: WordPress reverted back the system to its default theme (K2). I never encountered such problem before so I googled it. Sadly no satisfactory results had been found. Right now I’m just going to rename the theme to ‘default’, seems to be working fine. :)

(more…)

Related posts