Bertiethedog
Programmer
I get the "error on page"
The function "Handle_response" has the correct content so I assume there is something wrong with the "div" statement in the html
eventually I want to load a select menu
I havn't included the file getjob because it appears to work OK
A lot of the code has been copied off this site & I hope nobody minds
This is my javascript code in a seperate file
The function "Handle_response" has the correct content so I assume there is something wrong with the "div" statement in the html
eventually I want to load a select menu
I havn't included the file getjob because it appears to work OK
A lot of the code has been copied off this site & I hope nobody minds
Code:
<?php
error_reporting(E_ALL);
$custlst = custlst(0,4);
?>
<html>
<head>
<title>AJAX - loads a new script!</title>
<script type="text/javascript" src="ajax_lib.js"></script>
<style type="text/css">
#contents {
width : 500px;
height : 100px;
border : solid 1px #000;
}
</style>
</head>
<body>
<p> </p>
<form name="form1" method="post" action="">
<select onchange="javascript:send_request(this.value)" name="custcode" id="custcode">
<?php print $custlst ;?>
<div class="text" id="contents">Content for class "text" id "contents" Goes Here
</div>
</form>
</body>
</html>
This is my javascript code in a seperate file
Code:
// JavaScript Document
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer")
ro = new ActiveXObject("Microsoft.XMLHTTP");
else
ro = new XMLHttpRequest();
return ro;
}
function send_request(html_file_name) {
server_side_script = 'getjob.php?filename=' + html_file_name;
http.open('get', server_side_script);
http.onreadystatechange = handle_response;
http.send(null);
}
var http = createRequestObject();
function handle_response() {
if(http.readyState == 4){
var response = http.responseText;
var parts = response.split('~');
if(parts.length>1) {
load_script(parts[0]);
*-********* An alert at this point has the correct content
document.getElementById("contents").innerHTML = parts[1];
} else {
document.getElementById("contents").innerHTML = response;
}
}
}
function load_script(filename) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = filename;
document.getElementsByTagName('head')[0].appendChild(script);
}