Web Design and Development Forums

[SOLVED] ASP - AJAX (Retrieve Database Value Without Refreshing The Page)

This is a discussion on "[SOLVED] ASP - AJAX (Retrieve Database Value Without Refreshing The Page)" within the ASP Forum section. This forum, and the thread "[SOLVED] ASP - AJAX (Retrieve Database Value Without Refreshing The Page) are both part of the Program Your Website category.


Go Back   Webforumz.com > Program Your Website > ASP Forum

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old Jan 14th, 2008, 03:12   #1 (permalink)
Most Reputable Member
 
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
Blog Entries: 2
Send a message via Yahoo to Monie
[SOLVED] ASP - AJAX (Retrieve Database Value Without Refreshing The Page)

I've just know that this was a great way to display our data inside the database to be display in our page without keep refreshing the page for new incoming data!

Does anyone know how this thing is done? I mean, how do the XML code retrieve the data from my database and display it to my page?

Thanks..
__________________


Last edited by Monie; Jan 18th, 2008 at 07:45.
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 14th, 2008, 10:15   #2 (permalink)
Moderator
 
spinal007's Avatar
 
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,609
Blog Entries: 1
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: ASP - XML (Retrieve Database Value Using XML)

You use PHP/ASp to call the database and generate the XML.

This allows you to...
1. save it on the server and load the file with PHP/ASP without needing to make a database call
2. send the XML to the client and manipulate it with Javascript
...amongst other things
__________________
Diego - SEO Consultant London (My Blog | Fight Me)
jQuery: Star Rating - Multiple File Upload - FCKEditor/Codepress
Before we work on artificial intelligence why don't we do something about natural stupidity?
spinal007 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 14th, 2008, 18:44   #3 (permalink)
Administrator
 
alexgeek's Avatar
 
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 4,102
Blog Entries: 9
Send a message via MSN to alexgeek
Re: ASP - XML (Retrieve Database Value Using XML)

not really sure how XML parsing works in ASP. But in .NET and PHP it's extremely easy.
__________________
Languages: PHP, mySQL (queries), C#, (X)html, CSS, JS.


alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 14th, 2008, 20:40   #4 (permalink)
Moderator
 
spinal007's Avatar
 
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,609
Blog Entries: 1
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: ASP - XML (Retrieve Database Value Using XML)

It's not naturally as easy to do it in ASP, but there are open source classes out there that make it easy... But usually, the best use of XML is on the client.

If you cache XML on the server, you reduce the load on the database server, not on the web-server. But if you use a client-side interface to manipulate the XML, you reduce the load on the web-server AND the database server.

And the key thing is, database systems (such as MySQL and MSSQL) are built to deal with high-stress applications. The slowest part of a website is usually the web-server itself - not the database.

Hope that helps anyone...
__________________
Diego - SEO Consultant London (My Blog | Fight Me)
jQuery: Star Rating - Multiple File Upload - FCKEditor/Codepress
Before we work on artificial intelligence why don't we do something about natural stupidity?
spinal007 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 14th, 2008, 20:51   #5 (permalink)
Administrator
 
alexgeek's Avatar
 
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 4,102
Blog Entries: 9
Send a message via MSN to alexgeek
Re: ASP - XML (Retrieve Database Value Using XML)

I don't like to rely on the client side to manipulate XML personally.
Could you give me an example of when you would do this?
__________________
Languages: PHP, mySQL (queries), C#, (X)html, CSS, JS.


alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 14th, 2008, 21:05   #6 (permalink)
Moderator
 
spinal007's Avatar
 
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,609
Blog Entries: 1
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: ASP - XML (Retrieve Database Value Using XML)

erm... you got me there. I support the theory, but I haven't actually used this technique in any of my projects. You can throw me in the closet and tell me to "practice what you preach"...

But I would use this technique in any Ajax application that uses a permanent data source within a page - for local searching instead of calling the server over and over for a new 'filtered' copy.

AH! Yes I do use this, for several things actually, one of which is an email autocomplete input (an address book lookup)
__________________
Diego - SEO Consultant London (My Blog | Fight Me)
jQuery: Star Rating - Multiple File Upload - FCKEditor/Codepress
Before we work on artificial intelligence why don't we do something about natural stupidity?
spinal007 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 14th, 2008, 22:07   #7 (permalink)
Administrator
 
alexgeek's Avatar
 
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 4,102
Blog Entries: 9
Send a message via MSN to alexgeek
Re: ASP - XML (Retrieve Database Value Using XML)

Ahh fair play. Good use.
__________________
Languages: PHP, mySQL (queries), C#, (X)html, CSS, JS.


alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 15th, 2008, 02:39   #8 (permalink)
Most Reputable Member
 
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
Blog Entries: 2
Send a message via Yahoo to Monie
Re: ASP - XML (Retrieve Database Value Using XML)

This is a bit confusing!
What about AJAX/XML? Do they related in terms of displaying new data (from database) without refreshing the page?
__________________

Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 15th, 2008, 09:56   #9 (permalink)
Moderator
 
spinal007's Avatar
 
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,609
Blog Entries: 1
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: ASP - XML (Retrieve Database Value Using XML)

ok monie, I'll explain - and for that I will assume you understand these terms:
- client: the machine viewing the webpage, the visitor's computer
- server: the machine where your website is hosted
- database server: the machine where the database is hosted
(websites and databases are not usually hosted together)

Let's consider an address book lookup in Javascript, as I mentioned above.
you need:
a) Data - a "list" of names and email addresses
b) Functionality - the ability to search

Let's assume the 'data' is on your database server and the client will access it via your website.
1. Client requests page from web-server
2. Web-server runs script connects to database and retrieves data
3. Web-server processes data and sends a response
4. The response is processed by the client's browser (they see it some how)

In the most common scenario, the web-server will ask for the database to give it some data. The database server will take care of searching. The web-server will only deal with 'presenting the data'.

When the user searches again, you will have to go through all those stages again. This is a classic web-application - no caching involved - simple, raw, get the job done. But this isn't good enough if you care about performance or if you are building a large-scale application.

So that's where XML comes in (there are other formats but let's just assume XML is the way to do it)

If you save the data from the database on the web-server, you allow yourself to skip step 2. You don't have to call the database server again. But then, there will be more processing for the web-server to do. It will have to get the file from somewhere and perform any search functionality required.

If you use the web-server to send ALL the data to the client - let's say, in XML format - without any filters (not searched) then you can skip step 1, 2 and 3 from then on.
What happens now is that you leave the processing (searching through the data) to the client AND you cut off all the traffic between the client, your web server AND your database server.

Go to run - hope you understand it now!

(perhaps I could turn this into an article...)
__________________
Diego - SEO Consultant London (My Blog | Fight Me)
jQuery: Star Rating - Multiple File Upload - FCKEditor/Codepress
Before we work on artificial intelligence why don't we do something about natural stupidity?
spinal007 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 15th, 2008, 16:12   #10 (permalink)
Administrator
 
alexgeek's Avatar
 
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 4,102
Blog Entries: 9
Send a message via MSN to alexgeek
Re: ASP - XML (Retrieve Database Value Using XML)

I understand the concept but I don't see how you would store the XML on the client's machine.
__________________
Languages: PHP, mySQL (queries), C#, (X)html, CSS, JS.


alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 15th, 2008, 18:12   #11 (permalink)
Moderator
 
spinal007's Avatar
 
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,609
Blog Entries: 1
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: ASP - XML (Retrieve Database Value Using XML)

you don't store it as such - like saving a file, etc...

you just request it via javascript (Ajax), then it's stored in memory, until you leave or refresh the page.
__________________
Diego - SEO Consultant London (My Blog | Fight Me)
jQuery: Star Rating - Multiple File Upload - FCKEditor/Codepress
Before we work on artificial intelligence why don't we do something about natural stupidity?
spinal007 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 15th, 2008, 18:26   #12 (permalink)
Administrator
 
alexgeek's Avatar
 
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 4,102
Blog Entries: 9
Send a message via MSN to alexgeek
Re: ASP - XML (Retrieve Database Value Using XML)

I understand now. Thanks.
Would be a great article actually (in fact a tutorial would be preferable).
__________________
Languages: PHP, mySQL (queries), C#, (X)html, CSS, JS.


alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 15th, 2008, 20:48   #13 (permalink)
Moderator
 
spinal007's Avatar
 
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,609
Blog Entries: 1
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: ASP - XML (Retrieve Database Value Using XML)

I've never been good at writing tutorials, but I'll have a go at writing an article...
__________________
Diego - SEO Consultant London (My Blog | Fight Me)
jQuery: Star Rating - Multiple File Upload - FCKEditor/Codepress
Before we work on artificial intelligence why don't we do something about natural stupidity?
spinal007 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 16th, 2008, 00:20   #14 (permalink)
Most Reputable Member
 
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
Blog Entries: 2
Send a message via Yahoo to Monie
Re: ASP - XML (Retrieve Database Value Using XML)

I am new to this ASP-XML-AJAX things...

I've been googling around to learn the concept of "retrieving data from database without refreshing the page" things... and sadly I must say I have ended up with nothing, practically.
I understand the concept that you've explained to us, but practically.. I have no idea!

P/S: I have found some example in ASP/XML/AJAX for the ASP Chat, Search and Display, but it's not what I wanted to do!
What I want to learn is, when there is a new input in my database, it will trigger something to you, our PM Alert Message Popup Box is the close example that I can give you
__________________

Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 16th, 2008, 09:15   #15 (permalink)
Moderator
 
spinal007's Avatar
 
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,609
Blog Entries: 1
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: ASP - XML (Retrieve Database Value Using XML)

Forget about this conversation - it's too abstract and too advanced for you. I'm not sayin you will never get this, but you can only appreciate what we're talking about if you already know how to use databases (and I thought you did).

Start off by learning how to use a simple database (I'd recommend MS Access if you have MS Office or MySQL if you have one).

1. First learn about databases: how to make a table, etc
2. Then learn to read from/write to databases - there's tons of tutorials out there (1, 2, 3, 4, ...)
__________________
Diego - SEO Consultant London (My Blog | Fight Me)
jQuery: Star Rating - Multiple File Upload - FCKEditor/Codepress
Before we work on artificial intelligence why don't we do something about natural stupidity?
spinal007 is offline  
Digg this Post!Add Post to del.icio.us