Category: Javascript

  • HTML5 Quickstart Template – Mobile Viewport, CSS3, Google Font, Latest jQuery – All Ready

    Whenever I want to quickly make a webpage, I don’t want to have to build the whole page everytime. Here is my starter code for an HTML5 page. The key points are : HTML5 Doctype – Ready Viewport and Mobile – Ready Title tags, Character Set, Keyword and Description Meta, Favicon, Stylesheet tags – Ready…

  • HTML Actions vs Javascript Callbacks

    HTML actions: The action attribute specifies where to send the form-data when a form is submitted. In HTML5, the action attribute is no longer required. We can use javascript to send data on the backend using AJAX. http://www.w3schools.com/tags/att_form_action.asp Callbacks in javascript: In general, a callback function is used once another function you have called finishes.…

  • Reset your form after submit using jQuery

    After you submit a form, you reset it with the following code: $(“form#myform”)[0].reset(); For example on my Magic8Ball website, I created a function to submit the form and reset it immediately, clearing out the input elements. var formData = $(“#form”).serializeArray(); $.ajax({ url : “speaktome.php”, type: “POST”, data : formData, success: function(result) { $(“.youranswer”).hide().html(” + result…

  • Finding nested items in JSON object or associative array using PHP

    I had this problem recently when I used made a call to Yahoo Finance’s Stock quotes API for my Chinese website about US Stocks. Yahoo’s API returns the stock data in JSON form, but you can choose to handle it as a php object or associative array. First, this post by Michael Nitschinger really helped…

  • Preventing users from going backwards

    We created a quiz on driverstest.info that allows people to get coins if they get the right answer. If you get enough coins you can get on the high score list. However, I found that some people were using the back button on the browser and doing the same question again and again. The better idea…