Thanks a lot for the example. I still have one question. I understand how AJAX2 gets the customer # and sends back the response. I guess I don't understand how the html stuff on ajax2.html gets put on ajax1.html's page. What page do you reference in your gethtmlifs procedure in ajax2??
Thanks, Doug
----- Original Message ----
From: andrew_david_kerr <[EMAIL PROTECTED]>
To: [email protected]
Sent: Monday, March 13, 2006 4:40:31 AM
Subject: [Easy400Group] Re: AJAX and iSeries
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 = "" + 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!
>
----- Original Message ----
From: andrew_david_kerr <[EMAIL PROTECTED]>
To: [email protected]
Sent: Monday, March 13, 2006 4:40:31 AM
Subject: [Easy400Group] Re: AJAX and iSeries
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 = "" + 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!
>
SPONSORED LINKS
| How to format a computer hard drive | Cobol programmer | Iseries 400 |
| How to format a computer |
YAHOO! GROUPS LINKS
- Visit your group "Easy400Group" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
- Re: [Easy400Group] Re: AJAX and iSeries pdrula
- [Easy400Group] Re: AJAX and iSeries andrew_david_kerr
- Re: [Easy400Group] Re: AJAX and iSeries K. Schreur
- Re: [Easy400Group] Re: AJAX and iSeries mattlavinder
- [Easy400Group] Re: AJAX and iSeries andrew_david_kerr
- [Easy400Group] Re: AJAX and iSerie... andrew_david_kerr
- Re: [Easy400Group] Re: AJAX an... dp
- [Easy400Group] Re: AJAX an... andrew_david_kerr
- Re: [Easy400Group] Re: AJA... dp
- Re: [Easy400Group] Re: AJA... K. Schreur
- [Easy400Group] Re: AJAX an... andrew_david_kerr
- Re: [Easy400Group] Re: AJA... dp
- [Easy400Group] Re: AJAX an... andrew_david_kerr
- Re: [Easy400Group] Re: AJA... dp
- Re: [Easy400Group] Re: AJA... dp
- Re: [Easy400Group] Re: AJA... Bob P. Roche
- Re: [Easy400Group] Re: AJA... dp
- Re: [Easy400Group] Re: AJA... dp
- Re: [Easy400Group] Re: AJA... Buck Calabro
