...

Help. me. before. I. become. [drama]

thiscolddecembe
08-12-2007, 04:49 AM
Ajax is out there to k((i((l((l)) me. D:

edit.php

...
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
document.write("<center>"+ajaxRequest.responseText"</center><br>")
}
}
var name = document.getElementById('name').value;
var description = document.getElementById('description').value;
var query = "&name="+name"&description="+description"";
xmlHttp.Request.open("GET","edit_ss.php"+query,true);
xmlHttp.Request.send(null);
}
</script>
<?php
echo "<b>Note:</b> 'Last Name' needs to be ONE letter - Please start filling these in!</b>";
echo "<form id='thing'>";
echo "Name <input type='text' id='name'><br><br>Description<br><textarea cols=80 rows=10 value='".$row['description']."' id='description'></textarea><br><br><input type=submit value=Update! onClick='javascript: ajaxFunction()'></form>";
...
What's wrong with this?! I know I'm not a javascript guru..>_> But yeah. The code on "edit_ss.php" is correct; It GET's the vars and updates the DB with them.
Although this form just clicks and reloads the page.. and then doesn't update. x.x

[PS: The thumgs down is for how bad ajax can be to poor newbs. =p]
-TCD

rwedge
08-12-2007, 05:12 AM
To stop the form from reloading the page change the input type="submit" to type="button", or return false to stop the submit.

You will also have to change how you are handling the response.

Use a target element, like a division, span or paragraph and then access it by it's id:
if(ajaxRequest.readyState == 4){
document.getElementById('results').innerHTML="<center>"+ajaxRequest.responseText"</center><br>";
}


....



... <input type=button value=Update! onClick='javascript: ajaxFunction()'></form>";
...
<div id="results"></div>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum