Re: DB access problems
- From: "JoeyP" <plantz.3@xxxxxxxxxx>
- Date: 29 Dec 2006 11:17:10 -0800
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.
.
- References:
- DB access problems
- From: JoeyP
- Re: DB access problems
- From: Sherm Pendley
- DB access problems
- Prev by Date: running ppm on XP 64
- Next by Date: Re: Debug question
- Previous by thread: Re: DB access problems
- Next by thread: Re: DB access problems
- Index(es):
Relevant Pages
|