Monthly Archives: November 2014

How to make a JavaScript POST to a page

Scenario:

You want to post data from one page to another with JavaScript.

Solution:

First, create a JavaScript function in your page.  This will need to be surrounded by script tags and should probably live in the head tags (or have a js file included there):

JavaScript

function postwith (to,p) {
  var myForm = document.createElement("form");
  myForm.method="post" ;
  myForm.action = to ;
  for (var k in p) {
    var myInput = document.createElement("input") ;
    myInput.setAttribute("name", k) ;
    myInput.setAttribute("value", p[k]);
    myForm.appendChild(myInput) ;
  }
  document.body.appendChild(myForm) ;
  myForm.submit() ;
  document.body.removeChild(myForm) ;
}

Now, you can post via click (or other events) on elements. This example I’ll just use a hyperlink:

<a href="javascript:postwith('post.php',{firstname:'john',lastname:'smith'})">click</a>

How to clear/flush the DNS cache in Google Chrome

Scenario:

You want to clear/flush the DNS cache in Google Chrome.  This maybe necessary if you are a web developer and are working on updating the DNS pointers for your site (Note, you may need to flush the DNS cache in the OS also).

Solution:

Enter “chrome://net-internals/#dns” in the Chrome address bar, navigate there and then click the “Clear host cache” button.

Windows 8 – Workaround for Printer Appears Offline

Scenario:

The printer stops working after a set period of time.  Rebooting usually fixes the printing issue but after a period of time it starts again.  When you navigate to the active print jobs you will see what you wanted to print but the printer will list as “Offline”.

Solution 1:

Note that is a work around to the real issue.  The first thing you will want to do is see if your printer has updated drivers.  If that doesn’t work often times restarting the print spooler service will alleviate the issue.

  1. Press the windows key to pull up your local search.
  2. Type services and then choose “Services” from the results to open that control panel option.
  3. Navigate to “Print Spooler” in the main window.  Right click on that item and choose “Restart”.

Solution 2:

  1. Press the windows key+R to bring up a run dialog.
  2. Type “cmd” and click Ok to start a command prompt.
  3. Enter “net stop spooler” then press enter, wait for this command to complete.
  4. Enter “net start spooler” then press enter, wait for this command to complete.