[SOLVED] Please help - No error but code not working
Posted: Sat Sep 04, 2010 9:11 am
Hi I have a jQuery thats not working. Its suppose to display a value in the div "error" but nothings showing up.
Content of checklogin.php is just "hello" - just for error checking
Here's the code
Content of checklogin.php is just "hello" - just for error checking
Here's the code
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HP - Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<!-- Javascript -->
<script type = "text/javascript" src="jquery.js"> </script>
<script type = "text/javascript">
function checklogin() {
$.post( 'checklogin.php', {username: form.username.value},
function(error) {
$('#error').html(error).show()
});
}
</script>
<body>
<div id="wrap">
<div id="header">
<div id="logo">
<h1 id="sitename">H<span class="green">P</span></h1>
<h2 class="description"></h2>
</div>
<div id="headercontent"></div>
<div id="sitecption">
Welcome
<span class="bigger">Guest</span>
</div>
</div>
<div id="main">
<div id="menus">
<div id="mainmenu">
<ul>
<li class="first"><a href="home.php">Home</a></li>
<li id="active"><a href="login.php">Log In</a></li>
<li><a href="about.php">About</a></li>
<li><a href="services.php">Services</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
</div>
</div>
<div id="content">
<div id="homeleft">
<form name="login">
<table width="480" border="0">
<tr>
<th scope="col"><h2>User<span class="green">name</span></h2></th>
<td scope="col"><input type="text" name="username" /></th>
</tr>
<tr>
<th><h2>Pass<span class="green">word</span></h2></td>
<td><input type="password" name="password"/></td>
</tr>
<tr>
<td colspan="2"> <div id = "error" > </div> </td> - this is where the error or text from checklogin should show up.
</tr>
<tr>
<th></td>
<td>
<p> </p>
<input type="button" value="Submit" onClick="checklogin();"/>
</td>
</tr>
</table>
</form>
</div>
<div id="homeright">
</div>
<div class="clear"></div>
</div>
</div>
<div id="footer">
</div>
</div>
</body>
</html>