|
I think you are missing a small point. When the
page from Ajax1 sends the request, the program Ajax 2 is actually sending his
html back to the _javascript_ on page ajax 1 that is waiting for it. The
_javascript_ on the ajax 1 page is waiting for the reply through the
XmlHTTP.onreadystatechange. Once it receives it, the other _javascript_ is then
called to update the existing ajax 1 html page.
----- Original Message -----
Sent: Monday, March 13, 2006 3:55
PM
Subject: Re: [Easy400Group] Re: AJAX and
iSeries
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! >
SPONSORED LINKS
YAHOO! GROUPS LINKS
|