Re: IBM i as a webserver with low cost tools

Steve Richter <[email protected]>
Newsgroups gmane.comp.systems.as400.web
Message-ID <CAE0XMrPYK97kNdUN8-iU=cJyYGBdstNL_ZQy=jChaZcOFxFbXA@mail.gmail.com>
I use fetch on its own.   What is terrific about fetch is it works with
async await style code.  So no more javascript call backs.  And you do not
even have to deal with resolving and rejecting promises.

 I have some helper functions that prepare things the way the
function wants them.  When running fetch with the GET method, all the
parameters are passed up to the PHP web service in the query string.  The
query string is setup using another browser api named `encodeURIComponent`

  const url = `../../../site/common/json_getManyRows.php` ;
  const params = { libl, proc: 'pcarstyl_Select',
                parm1: effDate, parm2: style, parm3: styleName,
                parm4: collName,
                parm5: itcl, parm6: itsc, parm7: brandFlags,
                parm8: cono, parm9: csno, parm10: broadloom_outdoor_only,
                parm11: priceLevel, joblog:'N' };
  const query = object_toQueryString( params ) ;
  const url_query = `${url}?${query}`;

  const response = await fetch(url_query,
    {
      method: 'GET',
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    });

  const respText = await response.text();
  const rows = JSON.parse(respText);

// ------------------------- object_toQueryString
---------------------------------
function object_toQueryString( obj )
{
  const qs = Object.keys(obj)
    .map((key) => encodeURIComponent(key) + '=' + encodeURIComponent(obj[key
]))
    .join('&');
  return qs ;
}


On Wed, Jun 2, 2021 at 8:23 AM Jim Franz <[email protected]> wrote:

> Steve - any toolkits or sites avail for the  javascript fetch function to
> call PHP web services you described - or did you build your own?
> I found dropbox pretty easy to get into - several of the main pages have a
> phone/tablet version, but not yet for entire site.
> Thanks for the info
>
> Jim
>
>
>
>
> On Wed, Jun 2, 2021 at 12:00 AM Steve Richter <[email protected]>
> wrote:
>
> > I have gotten great results from bootstrap and vue.js on the
> client/browser
> > side, which use the javascript fetch function to call PHP web services,
> > which in turn call SQL procedures on the ibm i that return result sets to
> > the PHP, where the PHP converts the result set to JSON and echo the JSON
> to
> > the browser.    Not as involved as it sounds as the PHP web services are
> > generic, and the javascript fetch code and sql procedures are
> > implementations of the same pattern.
> >
> > The key is bootstrap - which is a great way to make decent looking web
> > pages.  And vue.js which, once you get the hang of it, enables the
> > programmer to write highly functional SPA web pages.
> >
> > -Steve
> >
> >
> > -Steve
> >
> >
> > On Tue, Jun 1, 2021 at 11:37 PM <[email protected]> wrote:
> >
> > > Given task to find framework and tools to migrate existing customer
> > service
> > > site (order entry, maintenance, history, payments, 60 different
> programs,
> > > all dynamic, heavily edited), and apply new UX dashboard design and
> > > functions to auto fit devices (not too much to ask is it?).
> > >
> > >
> > >
> > > This site has been up 21 years, with couple overhauls, built with a $$
> > tool
> > > (that I like but will not name..), uses Apache cgi interface. Site does
> > not
> > > fit any pattern like a shopping cart, or lookup portal. Half the site
> is
> > > pages of data entry (names and addresses, long descriptions, code
> > > selections). Already using CSS, jQuery for autocomplete and other
> > > functions,
> > > some javascript, some bootstrap. Ready for next overhaul.
> > >
> > >
> > >
> > > Primary business requirements are:
> > >
> > > No limits on handling business designs like other platforms ( - a great
> > > site)
> > >
> > > Annual software maint no more than low end/open source  (current annual
> > > maint 10k). The business thinks this savings will pay for project..
> > >
> > > They would prefer it not be a strictly RPG site (concern about
> > > maintainability long term) but not ruling it out - have used cgidev2
> > > before.
> > >
> > > Realtime updates to IBM I DB2 like an interactive application.
> > >
> > > Customer authentication, and secure.
> > >
> > >
> > >
> > > CSS will be replaced.
> > >
> > > Power 9 (small) is staying, but without a solution the website will be
> > > given
> > > to an external vendor with lots of calls to the system (and customer
> will
> > > be
> > > unhappy).
> > >
> > > Eventually this solution will be used to replace office applications.
> > >
> > > Average 20 - 30 near simultaneous users but must handle several times
> > > that.
> > >
> > >
> > >
> > > Am leaning towards PHP - but have not used since early days of Zend.
> > >
> > > Given the annual maint cost limits - is this realistic?
> > >
> > >
> > >
> > > Jim
> > >
> > >
> > >
> > >
> > >
> > > --
> > > This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400)
> mailing
> > > list
> > > To post a message email: [email protected]
> > > To subscribe, unsubscribe, or change list options,
> > > visit: https://lists.midrange.com/mailman/listinfo/web400
> > > or email: [email protected]
> > > Before posting, please take a moment to review the archives
> > > at https://archive.midrange.com/web400.
> > >
> > >
> > --
> > This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
> > list
> > To post a message email: [email protected]
> > To subscribe, unsubscribe, or change list options,
> > visit: https://lists.midrange.com/mailman/listinfo/web400
> > or email: [email protected]
> > Before posting, please take a moment to review the archives
> > at https://archive.midrange.com/web400.
> >
> >
> --
> This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
> list
> To post a message email: [email protected]
> To subscribe, unsubscribe, or change list options,
> visit: https://lists.midrange.com/mailman/listinfo/web400
> or email: [email protected]
> Before posting, please take a moment to review the archives
> at https://archive.midrange.com/web400.
>
>
-- 
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.