O'Reilly logo

CouchDB and PHP Web Development Beginner's Guide by Tim Juravich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — improving our user experience by using AJAX to delete posts

Let's get our feet wet with a bit of jQuery by adding some code to our master.js file that will allow us to delete posts using JavaScript. Don't be overwhelmed if the syntax of jQuery isn't familiar to you at first; stick with it, and I think you'll be incredibly pleased with the results.

  1. Open public/js/master.js, and make sure the jQuery code will run when the page is finished loading by adding a $(document).ready event to our file. This piece of code means that any JavaScript code inside of this function will be run once the page has finished loading:
    $(document).ready(function() {
    });
    
  2. Now, let's add an event that binds the click event to any button that has the delete ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required