× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Bruce,

I do not understand why you are trying to mix RSP and CGI.  RSP will handle
AJAX quite easily.  I think you are over complicating it.

Most of the examples I see on the web uses the GET method to submit.  I
prefer the POST method.  Less hoops to jump through.  Here is sample code on
how to use AJAX with RSP:

The HTML:

<html>

<head>

<title>RSP Ajax Example</title>

<script language="Javascript">

function xmlhttpPost(strURL) {

var xmlHttpReq = false;

var self = this;

// Mozilla/Safari

if (window.XMLHttpRequest) {

self.xmlHttpReq = new XMLHttpRequest();

}

// IE

else if (window.ActiveXObject) {

self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");

}

self.xmlHttpReq.open('POST', strURL, true);

self.xmlHttpReq.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');

self.xmlHttpReq.onreadystatechange = function() {

if (self.xmlHttpReq.readyState == 4) {

updatepage(self.xmlHttpReq.responseXML);

}

}

self.xmlHttpReq.send(getquerystring());

}

function getquerystring() {

var form = document.forms['form1'];

var intext = form.intext.value;

qstr = 'w=' + escape(intext); // NOTE: no '?' before querystring

return qstr;

}

function updatepage(str){

response = str.documentElement;

RJSNAM = response.getElementsByTagName('rjsnam')[0].firstChild.data;

RJFNAM = response.getElementsByTagName('rjfnam')[0].firstChild.data;

document.getElementById("result").innerHTML = "rjsnam = " + RJSNAM + "&
rjfnam = " + RJFNAM;

}

</script>

</head>

<body>

<form name="form1">

<p>Text: <input name="intext" type="text"> <input value="Go" type="button"

onclick='JavaScript:xmlhttpPost("/ajaxtest2.rsp")'></p>

</form>

<div id=result></div>

</body>

</html>


Here is the RSP that outputs the data in the format you needed:

<%
     D @TextEntered    S            256A
     D @Remote_Host    S            256A
     C                   EVAL      @TextEntered = RspGetVar('w')
     C                   EVAL      @Remote_Host=RspGetInfo('REMOTE_ADDR')
     C                   Callp     RspSetCnt('text/xml')
%>
<?xml version="1.0" ?>
<RPName>
  <rjresp>999</rjresp>
  <rjprof>99</rjprof>
  <rjprim>Y</rjprim>
  <rjsnam><%= @TextEntered %></rjsnam>
  <rjfnam><%= @Remote_Host %></rjfnam>
</RPName>
<%
     C                   Eval      *Inlr = *On
%>

I will send you this offline as well.

Let me know if you have any issues with this.

Schadd Gray
Prodata Computer Services, Inc.
RPG Server Pages
The Evolution of RPG
www.prodatacomputer.com/rsp.htm

----- Original Message ----- 
From: "Bruce Guetzkow" <bruceg@xxxxxxxxxxxxxxxxxxxxxxx>
To: <web400@xxxxxxxxxxxx>
Sent: Wednesday, June 21, 2006 5:05 PM
Subject: Re: [WEB400] Ajax via RSP/CGIDEV2


Thanks to all who have responded...

I was right to question where my XML was being written.  Under the CGIDEV2
covers when WrtSection('*fini') is called, IBM API QtmhWrStout is used to
write the string (in my case, XML) to "stdout".  It is doing this,
however,
stdout is being routed to QPRINT, which happens to be attached to a local
printer.  I got several pages of perfectly formatted XML (including my
Content-type line)!  Pretty to look at, but not really helpful in this
case.

How is this data supposed to be routed back to the client?  I suspect that
I
missed a step somewhere along the way, but I don't know what to look at.
I've re-directed stdout in REXX to a file at times, but I have no clue
what
to redirect it to (if I even need to do this myself).

I haven't posted to the Easy/400 forum, yet, but if that is the more
appropriate place, I can do that.

Curiouser and curiouser...
--Bruce Guetzkow

PS:  Bob, yes, I do read your articles, including the Ajax ones.  I don't
remember seeing anything specific to content-type, or even any server-side
code...perhaps you could direct me to a specific example.  As for the
tools,
they have been chosen and I believe they will do the trick...I am simply
new
to them.  I'm quite happy to do whatever research is needed, but at the
moment I'm a bit confused on where to look.  If anyone can point me in the
right direction, I'll take it from there.  At this point, I may just start
over, reinstalling/configuring each piece and making sure that I haven't
missed a step.


-- 
This is the Web Enabling the AS400 / iSeries (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.