473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Ajax + XML + MySQL

Hi, I'm using Perl CGI and HTML::Template to generate the following
XML:
----------------------------------------------------------------------
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xml" href="RR.xsl"?>
<!-- $Id: template.xml,v 1.5 2006/12/11 11:13:30 bcochofel Exp $ -->
<RR
xmlns:xsi="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://cochofel.sytes.net
~bcochofel/iweb/files/RR.xsd">
<Request>
<url>/~bcochofel/iweb/cgi-bin/getmysites.cgi</url>
<session>
<user>g...@cochofel.net</user>
</session>
<query>
<!-- o campo parametro pode ter varias ocurrencias -->
<param name="sort" value="asc" />
<param name="field" value="" />
</query>
</Request>
<Response>
<sites>
<site url="http://www.google.com">
<tag name="pesquisa" weight="30" />
<tag name="procura" weight="30" />
</site>
<site url="http://www.google.com/webhp?complete=1">
<tag name="ajax" weight="25" />
<tag name="pesquisa" weight="30" />
<tag name="procura" weight="30" />
</site>
<site url="https://webmail.fe.up.pt">
<tag name="email" weight="20" />
<tag name="feup" weight="20" />
</site>
</sites>
</Response>
</RR>
--------------------------------------------------------------
The Response element gets information from a MySQL DB and this is only
an example.

I'm creating a XSL file to transform this XML output in XHTML with the
results in a table, something like:

----------------------
| URL | TAG | WEIGHT |
----------------------

One URL can have several TAGS. URL is an attribute of the element
site.

What I want his to let the client click on the table tittle (url, tag
or weight) to sort the elements using that field, if the elements are
already sorted with that field then the order is toogle (ascending
and descending).

I want to do this in the client side using Ajax but I can't figure out
how to do this. How can I get the XML elements without querying the
MySQL server again? Can I do this? Does javascript has some object to
retrieve XML elements like this?

I'm using CGI::Ajax, a Perl module, but if I use this I'll have to
querie MySQL server again to resort the elements (at least I think I
have to...)

Can someone point me out some kind of solution to this? I'm a newbie
in using Ajax and XML.

Thanks,
Bruno

Dec 13 '06 #1
1 3318
I'm not a real expert on XML, but I do know that you can create an XML
document in memory in most browsers.

Microsoft uses its "Microsoft.XMLDOM" object, and I believe in Mozilla
you can simply create a new "document" (Although that I'm less sure
about). Once you have these objects you can load them up with whatever
XML you want -- presumably in your case the XML returned from your AJAX
request. You then have the XML stored on the client's machine and can
write some javascript stuff to output it as you would like.

Cheers,

Greg

bcochofel wrote:
Hi, I'm using Perl CGI and HTML::Template to generate the following
XML:
----------------------------------------------------------------------
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xml" href="RR.xsl"?>
<!-- $Id: template.xml,v 1.5 2006/12/11 11:13:30 bcochofel Exp $ -->
<RR
xmlns:xsi="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://cochofel.sytes.net
~bcochofel/iweb/files/RR.xsd">
<Request>
<url>/~bcochofel/iweb/cgi-bin/getmysites.cgi</url>
<session>
<user>g...@cochofel.net</user>
</session>
<query>
<!-- o campo parametro pode ter varias ocurrencias -->
<param name="sort" value="asc" />
<param name="field" value="" />
</query>
</Request>
<Response>
<sites>
<site url="http://www.google.com">
<tag name="pesquisa" weight="30" />
<tag name="procura" weight="30" />
</site>
<site url="http://www.google.com/webhp?complete=1">
<tag name="ajax" weight="25" />
<tag name="pesquisa" weight="30" />
<tag name="procura" weight="30" />
</site>
<site url="https://webmail.fe.up.pt">
<tag name="email" weight="20" />
<tag name="feup" weight="20" />
</site>
</sites>
</Response>
</RR>
--------------------------------------------------------------
The Response element gets information from a MySQL DB and this is only
an example.

I'm creating a XSL file to transform this XML output in XHTML with the
results in a table, something like:

----------------------
| URL | TAG | WEIGHT |
----------------------

One URL can have several TAGS. URL is an attribute of the element
site.

What I want his to let the client click on the table tittle (url, tag
or weight) to sort the elements using that field, if the elements are
already sorted with that field then the order is toogle (ascending
and descending).

I want to do this in the client side using Ajax but I can't figure out
how to do this. How can I get the XML elements without querying the
MySQL server again? Can I do this? Does javascript has some object to
retrieve XML elements like this?

I'm using CGI::Ajax, a Perl module, but if I use this I'll have to
querie MySQL server again to resort the elements (at least I think I
have to...)

Can someone point me out some kind of solution to this? I'm a newbie
in using Ajax and XML.

Thanks,
Bruno
Dec 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ivan Marsh | last post by:
Hey Folks, I'm having a heck of a time wrapping mind around AJAX. Anyone know of a simple, straight-forward example for pulling a simple query from mysql with PHP using AJAX? As I...
1
by: www.web20developers.com | last post by:
http://www.web20developers.com http://www.web20developers.com/index.php?option=com_content&task=view... Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell AJAX -...
1
by: bcochofel | last post by:
Hi, I'm using Perl CGI and HTML::Template to generate the following XML: ---------------------------------------------------------------------- <?xml version="1.0" encoding="iso-8859-1"?>...
1
by: rocksoft | last post by:
Hi, i have devloping web application in Asp.net and c#, i have used ajax to achieve the auto complete text box, my company using visual studio 2003, ajax auto complete text box...
6
jafarsalam
by: jafarsalam | last post by:
hi; I'm new to PHP and AJAX MySQL codes. I found a simple code for PHP and AJAX MySQL Database communication on : http://www.w3schools.com/php/php_ajax_database.asp I downloaded the code and...
4
abdoelmasry
by: abdoelmasry | last post by:
Hi Prof's im new in ajax i need some help i wanna create active web page linked to mysql database i mean .. i open my page , it will automatically view database contents
3
by: jarremw | last post by:
hello all, what i have is a modal popup control extender, i have an ajax script that saves the value of the two textboxes that are in the popup, what i am needing is a way to insert those values into...
4
kelleyvanevert
by: kelleyvanevert | last post by:
Hello everyone, This question is often asked, and I know there are lots and lots of answers that I could be using, but I just want a clear good answer. I am making a website (for playing a game...
1
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.