Category Archives: general

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!!

Firebug, Pitfalls and Videos

Decided this is a good place to put notes for my final report – mostly critical evaluation, rather than a word document where i’ll never rememeber the title and end up opening a different one each time, at least here they’re in one place and i can browse through and pick bits out that might be useful.

So firstly testing – i have discovered how useful the firebug extension for firefox is. I’ve had it for ages and never used it but it’s fantastic. I found it particularly useful when developing the Ajax sections of the site as i could tell whether or not the script was making the ajax call and whether the problem was with an other area of the code. It was sometimes one or the other, but then i could fix the relevent bit instead of spending hours just messing around wondering what wasn’t working.

Secondly pitfalls – how did i create them? Basically, in most cases i entered the first tags that came to mind when i thought of the video. I figured that as this would make them the tags that took least cognitive effort to create, this would make it likely that players of the game would also think of the same tags. Some are very basic, some not so. I did watch a couple of videos and come up with tags that were based on objects or words that stood out. This was especially the case for videos in tougher levels where more pitfalls needed to be found.

What criteria did i use to select the videos? A painful process of watching clips, seeing if they made me laugh or at least smile, sometimes then having to rule them out because although the begining was funny it got a bit silly toward the end. I was also careful to avoid videos with strong language, sexual references or violence – so that ruled out half of what i had looked at. I have let the odd mild violence video through – comparable with Tom and Jerry or The Simpsons levels of violence and there is the odd isolated case of strong language. As my demographic age range is over 18’s then i reasoned that the content was suitable for the percieved audience. Some videos aren’t histerically funny, but were ‘nice’ videos, or scary or simply high rated and i was running out of time and patience so they’ve made it in there. 3 of the videos are what 3 very kind people uploaded to my youtube group. If i get more and they are suitable, i will consider adding some extra videos to the game over the next couple of months as it will keep it fresh.

I have one problem left to fix with the game points and the tags not updating from a set timeout function which is frustrating – again it’s because i’m trying to be clever and use ajax! i need to build my admin section and create a questionnairre. i think that’s it i’m so close, i reckon 3 or 4 hurdles to go to the finish line.

nervous tick

My stress levels for this project are already reaching the levels they get to toward the end of a module, when there’s a couple of weeks left until a deadline and i still have practically the whole assignment left to do.  I always got it done and did it well too.  I’m seeing my literature review as a deadline and i need to get that done before moving on to anything else.  I have developed the nervous tick in my right eye that comes the week before a deadline normally.  I have 5 months before my project has to be submitted i hope i don’t have a nervous tick for that whole time i’ll have a full head tick by the end then i think.  I’ll feel loads better when i get the lit review done, i can’t believe how much grief it’s causing me.  Maybe i need to stop writing stupid blog entries and actually start doing some work, that may help.

With Best Intentions

I started this blog at the beginning of this project with all best intentions of documenting my progress. Then i never got around to actually writing in it. I was just so busy with the research! I did write a couple of notes down though with the intention of putting it into the blog, but never did, so i will add them later. When i created this blog it was part of my initial research into web 2.0, I didn’t know a lot about it and i wanted to use the technology as well as finding out current research in the area. I had used some web 2.0 sites without realising what i was doing – myspace, flickr, youtube, but i hadn’t tagged anything in my life and was having trouble embracing the whole social network thing. I am the person who stands in a corner or the kitchen at a party with a little safety net of friends and waits for people to talk to me – behaviour i’ve noticed i repeat on these social sites, which i think is really interesting. It seems even anonymity cannot ease my social anxiety.

I have now got to the point at my project where i can take a little break and catch up on some of the things i had initially wanted to do, like this blog. I’ve finished my proposal, i’m waiting for it to be approved, so it seemed a good time to do this. Now this blogs set up I can easily find the time to update it as i go along. I want to document any successes as they are the bits you tend to forget when critically evaluating a project. I also want to document all hurdles faced and the solutions to them. I want to be able to look back at the stages where all was hopeless and the project was a complete disaster and never going to get finished and see how i turned it around and how great that feels. It happens in every project i know it will happen lots in this one too!