Re: DB access problems




Sherm Pendley wrote:
"JoeyP" <plantz.3@xxxxxxxxxx> writes:

I have placed the AJAX app. on a Linux server and can access it from
the web. It is now time for me to query the DB (which I am able to do
already), take that data and pass it to a JavaScript function that will
format the data for my array that will populate the list.

Problem: I don't know how to do that.

Questions: Do I have to build the HTML with statements like print
"<html>\n"; in my CGI?

Good $DEITY no! That would defeat the purpose of using AJAX in the first
place. What you want to produce on the server is either XML or JSON, not
HTML. You then use JavaScript on the client to request the XML/JSON data,
and access the DOM to populate the list using the fetched data.

You should be sure to send the correct MIME type from your server script;
neither XML nor JSON is text/html!

JSON is easy to produce from a (possibly complex and/or deeply nested) Perl
data structure - have a look at the JSON module on CPAN.

I guess I'm not sure about the layout and how to put it together.

The key is that it isn't just a single request, it's two or more. The first
request is for the empty HTML page. Additional requests are then made from
JavaScript, to fetch data in XML or JSON format and manipulate the page's
DOM to format that data.

have read and searched online but have not found any examples for what
I want to do.

You've *got* to be kidding. There are AJAX tutorials in abundance out there -
just google for "AJAX tutorial".

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


I see. I'll check out the modules you mentioned. Your right, I have
found gangs of AJAX apps., I was just looking for a CGI I could
manipulate and get something working. Thanks again. I'll see what I can
find out about JSON module on CPAN.

Thanks again.

.



Relevant Pages

  • Re: DB access problems
    ... That would defeat the purpose of using AJAX in the first ... What you want to produce on the server is either XML or JSON, ... The key is that it isn't just a single request, ...
    (comp.lang.perl.misc)
  • Re: AJAX vs. JSON : Google Trends
    ... this sort of thing don't you think you should make some sort of point? ... AJAX and JSON possible usage trends is a noise at c.l.j.? ... called AJAX is board room pencil pushing pundits wanting to brag at the country club about "we use AJAX". ... history as well as the most popular requests of the year 2006 ...
    (comp.lang.javascript)
  • Re: AJAX without Rails
    ... friend told me Rails was a bit to much for what I need, ... How do Ajax work for ruby? ... of it and use HTML or JSON to deal with it. ... If you want to include JSON data and do DOM manipulation directly, ...
    (comp.lang.ruby)
  • Re: .net objects to javascript?
    ... ActiveX is bad, internally handled AX objects would do fine. ... > yes I already knew about ajax, but didnt know about json so I am going to ... >>> alex. ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: When is a string a number?
    ... Perl users don't experience these issues on a regular basis if ever. ... I moved from JSON to JSON Syck. ... JSON module is a purl perl module and does "the right thing" ...
    (perl.dbi.users)