Jump to content

Help with submitting information using AJAX


adamlacombe

Recommended Posts

I am trying to use this ajax:

<!-- 
//Browser Support Code
function ajaxStatus(){
var ajaxRequest;  // The variable that makes Ajax possible!

try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
} catch (e){
	// Internet Explorer Browsers
	try{
		ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try{
			ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e){
			// Something went wrong
			alert("Your browser broke!");
			return false;
		}
	}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
	if(ajaxRequest.readyState == 4){
		var ajaxDisplay = document.getElementById('ajaxform');
		ajaxDisplay.innerHTML = ajaxRequest.responseText;
	}
}
var status = document.getElementById('status').value;
var mood = document.getElementById('mood').value;
var queryString = "?status=" + status + "&mood=" + mood;
ajaxRequest.open("GET", "ajax/status.php" + queryString, true);
ajaxRequest.send(null); 
}

//-->
</script>

 

the form

echo '<form id="ajaxform"> <div class="content">


<b>Status:</b><input id="status" type="text" name="status" size="17" value="'.$status.'">

<b>Mood:</b><select name="mood">
<option value="'.$mood.'">'.$mood.'</option>
<option value="Angry">Angry</option>
<option value="Busy">Busy</option>
<option value="bored">Bored</option>
<option value="Calm">Calm</option>
<option value="Cold">Cold</option>
<option value="Confused">Confused</option>
<option value="Content">Content</option>
<option value="Curious">Curious</option>
<option value="Crazy">Crazy</option>
<option value="Depressed">Depressed</option>
<option value="Drunk">Drunk</option>
<option value="Emo">Emo</option>
<option value="Embarrassed">Embarrassed</option>
<option value="Energetic">Energetic</option>
<option value="Envious">Envious</option>
<option value="Exhausted">Exhausted</option>
<option value="Flirty">Flirty</option>
<option value="Full">Full</option>
<option value="Grumpy">Grumpy</option>
<option value="Happy">Happy</option>
<option value="Hot">Hot</option>
<option value="Hippie">Hippie</option>
<option value="Hungry">Hungry</option>
<option value="Hyper">Hyper</option>
<option value="Indescribable">Indescribable</option>
<option value="Lazy">Lazy</option>
<option value="Loved">Loved</option>
<option value="Mischievous">Mischievous</option>
<option value="Okay">Okay</option>
<option value="Nerdy">Nerdy</option>
<option value="Pissed">Pissed</option>
<option value="Relaxed">Relaxed</option>
<option value="Relieved">Relieved</option>
<option value="sad">Sad</option>
<option value="Scared">Scared</option>
<option value="Sick">Sick</option>
<option value="Silly">Silly</option>
<option value="Sleepy">Sleepy</option>
<option value="Smart">Smart</option>
<option value="Stressed">Stressed</option>
<option value="Thoughtful">Thoughtful</option>
<option value="Worried">Worried</option>
<option value="Tired">Tired</option>
<option value="Working">Working</option>
</select>
<p><input type="button" onClick="ajaxStatus()" value="update"></p>

</div></form>';

 

Im not sure why it isn't working correctly.. it doesn't do anything when I click the button.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.