A very simple example, but as you say once one works...
My ajax1.pgm simply outputs a page with an input box for a customer
number. WIth a change in this box, it fires a request for other
customer info (ajax2.pgm) back to the 400. You will see in the
updatePage function that it splits up the string that comes back from
the 400: we tell it that have used the "|" to indicate the break
between data items.
/$top
Content-type: text/html
<script TYPE="text/JavaScript">
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
function callServer() {
var cuno = document.getElementById("cuno").value;
// Build the URL to connect to
var url = "/cgiprdp/AJAX2.pgm?cuno=" + escape(cuno);
// Open a connection to the server
xmlHttp.open("GET", url, true);
// Setup a function for the server to run when it's done
xmlHttp.onreadystatechange = updatePage;
// Send the request
xmlHttp.send(null);
}
function updatePage() {
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText.split("|");
Cust_Name.innerHTML = response[0];
Cust_Group.innerHTML = "Customer Group__: " + response[1];
}
}
</script>
<html>
<head>
<title>AJAX *** TEST ***</title>
</head>
<body>
<table border=0>
<tr><td>Customer Number_: <input type="text" name=cuno size=10
maxlength=10 onChange="callServer()"></td><td><div id="Cust_Name"
></div></td>
</tr>
<tr> <td><div id="Cust_Group" ></div></td> <td></td>
</tr>
</table>
/$end
</body>
</html>
The ajax2 program simply looks to a customer master file with the
given number and returns 2 items of data relating to that customer.
It then does
callp wrtsection('top');
callp wrtsection('end');
callp wrtsection('*fini');
The html for ajax2 only contains the following
/$top
Content-type: text/html
/$end
/%cunm%/|/%cucl%/
So the response text just comes back as one long string. If you
wanted to return multiple lines, if would just be a case of deciding
on another character for identifying lines breaks, and writing the
javascript to break it up. That previous link that I gave
(onlamp.com) gives a great example of that. Hope this helps!
--- In [email protected], dp <[EMAIL PROTECTED]> wrote:
>
> Andrew - congrats! I'm having a hard time putting it all together
as I'm not very fluent in _Javascript. Would you be so kind to
upload your HTML and RPGILE program. Once I get one to work, the
others should fall neatly into place. THANKS!
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Easy400Group/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/