Category Archives: VideoTag

Ajax GET and POST

I’m posting my GET and POST ajax code it will hopefully be useful to some people.

I searched a lot to find some simple code as i didn’t need to validate the forms. So many scripts didn’t work properly or seemed unnecesserily complicated for my requirements.

The code has been adapted from

the GET from:

Hope you find this helpful!

//Set up the XMLHttpRequest

var http = createRequestObject();
function createRequestObject() {
var objAjax;
var browser = navigator.appName;
if(browser == “Microsoft Internet Explorer”){
objAjax = new ActiveXObject(“Microsoft.XMLHTTP”);
objAjax = new XMLHttpRequest();
return objAjax;


function getNewContent(){‘get’,’newcontent.php’);
http.onreadystatechange = updateNewContent;
return false;

function updateNewContent(){
if(http.readyState == 4){
document.getElementById(‘Content’).innerHTML = http.responseText;


function postForm() {
var url = “formentry.php”;
var formtag = document.getElementById(‘fmfield’).value;
var params = “newfield=” + formfield;“POST”, url, true);

//Send the proper header information along with the request
http.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);
http.setRequestHeader(“Content-length”, params.length);
http.setRequestHeader(“Connection”, “close”);

http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
document.getElementById(‘fomentered’).innerHTML = http.responseText;
document.getElementById(‘fmfield’).value = “”;

the functions are called through an onclick event
GET <a href=”#” onclick=”getNewContent()”>New Content</a>
POST <a href=”#” onclick=”postForm()”><img src=”Submit.gif”></a>

I couldn’t get it to work properly with a button with type image and i wanted an image so i did it with an <a> tag – i think it works with a normal <input type=”button” onclick=”postForm()”> But it won’t work if you have an <input type=”submit”> button.

I am still trying to figure out how to get it to work when the user presses return or enter – it calls the postForm() but refreshes the page.

If any one can help me on this please comment!!

Post your favourite videos

I’ve created a youtube group for VideoTag so that any kind people out there can join the group and post some of their favourite videos to it. If they’re suitable then they will be included in the game.

Here’s the link:

Register to Play VideoTag

I am in the process of building the VideoTag game. There is a registration page live at the moment. If you are interested in the VideoTag project and would like to register an interest to play the game, I will email you when the game is live and you will be able to log straight in and play.

Here is the link to register: