This is an ajax practice script. The ajax object is created ( a javascript alert tells me). The problem is I can't get the javascript to place the innerHTML between the right (or any) <li> and </li> tags.
There is a link in the code, but ajax is supposed to execute onload without clicking anything. A side effect - Clicking on the "Close" link pops up an alert box I wrote that says the object has been created. Hmmm...
A very basic php script written as simple as possible:
PHP Code:
<?php
if(isset($_POST["zip"]))
{
echo "Thank You";
}
?>
The javascript
:
Code:
<!DOCTYPE html>
<html>
<head><script src="/A2EB891D63C8/avg_ls_dom.js" type="text/javascript"></script>
<title>Test Ajax</title>
</head>
<body>
<div id='May12012' style="text-align: center;
width: 27em;
height: 18em;
background: #B3ECFF;
margin-bottom: 2em;"
></li>
<p style='font-size: .8em;'>$M3 $hi Schedule</p>
<form>
<ul id='May120128AM' name="apt_time" value='May120128AM' style="list-style-type: none;
margin: 0;
padding: 0;"
>
<input type="hidden" name="user_id" id='May120128AMhidden' value='u'/>
<li id = 'May120128AM_Scheduled_Cancel' style="display: inline;
width: 200px;
height: 50px;
background: #ccc;
text-align: center;
padding: .3em;"
></li>
<li id='May120128AM_Not_Available' style="display: inline;
width: 200px;
height: 50px;
background: #ccc;
text-align: center;
padding: .3em;"
></li>
<li id='May120128AM_Available' style="display: inline;
width: 200px;
height: 50px;
background: #ccc;
text-align: center;
padding: .3em;"
></li>
</ul>
</form>
<p><a href='' onClick=\"hideSchedule('$M3$hi$Y','$m'); return false\">Close</a></p>
<br />
</div>
<script type="text/javascript">
<!--
var request;
request = new XMLHttpRequest();
//} catch (e) {
//if(request=undefined) alert('e.message');
//}
if(request)
{
alert('XMLHttpRequest Created');
}
//-->
</script>
<!--//ONLOAD 8AM//-->
<script type="text/javascript">
<!--
//function checkData()
//{
//alert(request.readyState);
//}
var apt_time = encodeURIComponent(document.getElementById('May120128AM').value);
var userid = encodeURIComponent(document.getElementById('May120128AMhidden').value);
var parameters = "apt_time="+apt_time+"&user_id="+userid;
request.open("POST", "/cgi-bin/test_ajax.php", true);
//request.onreadystatechange = checkData;
request.onreadystatechange = function()
{
if(request.readyState == 4)
{
if(request.status == 200)
{
if(request.responseText == "Thank You")
{
var ajaxAnswer=document.getElementById('May120128AM_Available');
ajaxAnswer.innerHTML = "<p>Available</p><button id='May120128AM_Click_To_Schedule' name="apt_time" value='May120128AM' onClick="clickToSchedule(); return false">Click Here To Schedule</button>
}
}
}
}
request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
request.send(parameters);
//-->
</script>
<!--<p>END ONLOAD 8AM</p>//-->
</body>
</html>