DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Andy Guest

    Getting Data Without Refreshing Page


    Hi,

    Does anybody know if it is possible to retrieve data from a database and
    update to the page without actually refreshing the whole page?

    As an example, say I have 10,000 people's name from the database listed in
    a drop down combo box. I select a person from the drop down list, for which
    I then use some script to put that persons age into a text field.

    My problem is that I have bandwidth limits (10,000 people's names, Ahhhh),
    and so the solution is to enter the person’s name, and send this to the server
    to let SQL Server get the age. But the only method I know how is to reload
    the whole page again.

    Is there a method of executing some client script, which calls some server
    script, which in turn passes data back to the client script, which can then
    be populated into fields on the page?

    I welcome any ideas, suggestions, solutions.

    Thanks


  2. #2
    Sachin Guest

    Re: Getting Data Without Refreshing Page

    do something like this:-
    'client side script:-
    var i = <%= SomeASPFunction()%>;

    'server side
    Function SomeASPFunction()
    '
    '
    '
    SomeASPFunction = result
    End Function

    with this method its easy to get one or two values from the server side...if
    you more values you can try returning back an array ( I have'nt tried that
    myself ) :-)
    Sachin

    "Andy" <andy_boyd@yahoo.co.uk> wrote in message
    news:3b5d27cd$1@news.devx.com...
    >
    > Hi,
    >
    > Does anybody know if it is possible to retrieve data from a database and
    > update to the page without actually refreshing the whole page?
    >
    > As an example, say I have 10,000 people's name from the database listed in
    > a drop down combo box. I select a person from the drop down list, for

    which
    > I then use some script to put that persons age into a text field.
    >
    > My problem is that I have bandwidth limits (10,000 people's names, Ahhhh),
    > and so the solution is to enter the person's name, and send this to the

    server
    > to let SQL Server get the age. But the only method I know how is to

    reload
    > the whole page again.
    >
    > Is there a method of executing some client script, which calls some server
    > script, which in turn passes data back to the client script, which can

    then
    > be populated into fields on the page?
    >
    > I welcome any ideas, suggestions, solutions.
    >
    > Thanks
    >




  3. #3
    Harish Kumar Guest

    Re: Getting Data Without Refreshing Page


    Hello Andy,

    You can use client pull technology in this case. The concept behind this
    is pretty simple. At regular intervals of time, the web page will connect
    and dynamically pull updated data from the web server. You should specify
    the time intervals and the URL to connect to like this -

    <meta http-equiv="refresh" content="10; URL="http://mywebserver.com/clientpull.asp">

    HTH,
    Harish
    "Andy" <andy_boyd@yahoo.co.uk> wrote:
    >
    >Hi,
    >
    >Does anybody know if it is possible to retrieve data from a database and
    >update to the page without actually refreshing the whole page?
    >
    >As an example, say I have 10,000 people's name from the database listed

    in
    >a drop down combo box. I select a person from the drop down list, for which
    >I then use some script to put that persons age into a text field.
    >
    >My problem is that I have bandwidth limits (10,000 people's names, Ahhhh),
    >and so the solution is to enter the person’s name, and send this to the

    server
    >to let SQL Server get the age. But the only method I know how is to reload
    >the whole page again.
    >
    >Is there a method of executing some client script, which calls some server
    >script, which in turn passes data back to the client script, which can then
    >be populated into fields on the page?
    >
    >I welcome any ideas, suggestions, solutions.
    >
    >Thanks
    >



  4. #4
    Matthew Solnit Guest

    Re: Getting Data Without Refreshing Page

    "Andy" <andy_boyd@yahoo.co.uk> wrote in message news:3b5d27cd$1@news.devx.com...
    > As an example, say I have 10,000 people's name from the database listed in
    > a drop down combo box. I select a person from the drop down list, for which
    > I then use some script to put that persons age into a text field.


    You can store the person's age in the VALUE attribute of the OPTION element.
    Then write a client-side script that handles the onchange() event and displays
    the age of the selected person.

    -- Matthew Solnit



  5. #5
    Russell Jones Guest

    Re: Getting Data Without Refreshing Page

    Use remote scripting or (with IE-only clients) the XMLHTTPRequest object to
    make background queries to the server that post and retrieve data without
    refreshing the page. These techniques are not only relatively easy to
    implement, but will change the way you design your applications.


    "Andy" <andy_boyd@yahoo.co.uk> wrote in message
    news:3b5d27cd$1@news.devx.com...
    >
    > Hi,
    >
    > Does anybody know if it is possible to retrieve data from a database and
    > update to the page without actually refreshing the whole page?
    >
    > As an example, say I have 10,000 people's name from the database listed in
    > a drop down combo box. I select a person from the drop down list, for

    which
    > I then use some script to put that persons age into a text field.
    >
    > My problem is that I have bandwidth limits (10,000 people's names, Ahhhh),
    > and so the solution is to enter the person's name, and send this to the

    server
    > to let SQL Server get the age. But the only method I know how is to

    reload
    > the whole page again.
    >
    > Is there a method of executing some client script, which calls some server
    > script, which in turn passes data back to the client script, which can

    then
    > be populated into fields on the page?
    >
    > I welcome any ideas, suggestions, solutions.
    >
    > Thanks
    >




  6. #6
    Brian Barnett Guest

    Re: Getting Data Without Refreshing Page


    "Russell Jones" <arj1@northstate.net> wrote:
    >Use remote scripting or (with IE-only clients) the XMLHTTPRequest object

    to
    >make background queries to the server that post and retrieve data without
    >refreshing the page. These techniques are not only relatively easy to
    >implement, but will change the way you design your applications.
    >
    >
    >"Andy" <andy_boyd@yahoo.co.uk> wrote in message
    >news:3b5d27cd$1@news.devx.com...
    >>
    >> Hi,
    >>
    >> Does anybody know if it is possible to retrieve data from a database and
    >> update to the page without actually refreshing the whole page?
    >>
    >> As an example, say I have 10,000 people's name from the database listed

    in
    >> a drop down combo box. I select a person from the drop down list, for

    >which
    >> I then use some script to put that persons age into a text field.
    >>
    >> My problem is that I have bandwidth limits (10,000 people's names, Ahhhh),
    >> and so the solution is to enter the person's name, and send this to the

    >server
    >> to let SQL Server get the age. But the only method I know how is to

    >reload
    >> the whole page again.
    >>
    >> Is there a method of executing some client script, which calls some server
    >> script, which in turn passes data back to the client script, which can

    >then
    >> be populated into fields on the page?
    >>
    >> I welcome any ideas, suggestions, solutions.
    >>
    >> Thanks
    >>

    >
    >

    I've used Remote Scripting and that works great if your browser (IE or Netscape)
    is on Windows. If your clients will potentially be on a Mac then you can't
    use Remote Scripting (if someone knows how to do it on a Mac please let me
    know).

    I have a similar situation in that I have a page with two drop down lists.
    The client environment is a mix of Windows and Mac, IE and Netscape.

    The first list contains a small number of elements (approx. 57). The second
    drop down list needs to be filtered based on the selection in the first list.
    A technique I'm thinking about is this:
    When the user selects an item from list one I call a client-side JS function
    that opens a tiny browser child window, loading another ASP to retrieve the
    data from the database, filtered on the ID of the item selected in list one.
    Once the data is retrieved my child ASP will generate client-side JS to
    populate the second list on the parent window, since the child window has
    a reference to it's parent window and thus a reference to the controls on
    the page.

    This is still theory and I have not tried it out yet. I hope to be able
    to try it out in the next couple of weeks on the app I'm developing.

    Thanks


  7. #7
    Scott Bockelman Guest

    Re: Getting Data Without Refreshing Page


    Andy,

    I have done this using various techniques in several production applications
    running successfully now for 2+ years.

    The best way, in my opinion, is to use a Java Applet and LiveConnect (JavaScripting
    of Java Applets). It does work in both IE and Netscape.

    I cannot, obviously publish any source code here, but I can point you in
    the right direction.

    You want to end up with an applet on the page that is sized to 1x1 pixels,
    so it is practically invisible and that exposes at least 1, possibly 2, public
    methods for getting information from a remote URL.

    I suggest methods such as String getURLContent( sURL, sBaseURL, bIgnoreCache
    ) and Enumeration getURLLines( sURL, sBaseURL, bIgnoreCache ).

    Your client-side JavaScript can call these methods like so:

    var newContent = document.applets['myAppletName'].getURLContent( "../include/getOptionsByKey.asp?key=x",
    document.URL, true );

    In the Java implementation of these methods, you need to create the following
    objects, java.net.URL and java.io.BufferedReader.

    You'd do something like this:

    StringBuffer buf = new StringBuffer();
    URL baseURL = getDocumentBase();
    URL url = new URL( baseURL, theURL );
    URLConnection conn = url.openConnection();
    conn.setUseCaches(false);
    conn.connect();
    br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    while ( ( inputLine = br.readLine() ) != null ) {
    buf.append(inputLine).append("\n");
    }
    br.close();
    return buf.toString();

    Now all you need is an ASP page whose url you can pass to the applet method
    that will return some string you can do something with, like use to populate
    a drop down list or a text box with a user's age, or whatnot.

    P.S. I'd suggest you not start off with a select box with 20,000 names in
    it. How about using this same technique to have the user first choose some
    category (even if just the first letter of the name) that returns a subset
    of that list.

    I hope this helps.

    Scott Bockelman
    Vertek Corporation





    "Andy" <andy_boyd@yahoo.co.uk> wrote:
    >
    >Hi,
    >
    >Does anybody know if it is possible to retrieve data from a database and
    >update to the page without actually refreshing the whole page?
    >
    >As an example, say I have 10,000 people's name from the database listed

    in
    >a drop down combo box. I select a person from the drop down list, for which
    >I then use some script to put that persons age into a text field.
    >
    >My problem is that I have bandwidth limits (10,000 people's names, Ahhhh),
    >and so the solution is to enter the person’s name, and send this to the

    server
    >to let SQL Server get the age. But the only method I know how is to reload
    >the whole page again.
    >
    >Is there a method of executing some client script, which calls some server
    >script, which in turn passes data back to the client script, which can then
    >be populated into fields on the page?
    >
    >I welcome any ideas, suggestions, solutions.
    >
    >Thanks
    >



  8. #8
    Fred Guest

    Re: Getting Data Without Refreshing Page


    I would use <META HTTP-EQUIV="REFRESH" CONTENT="5;pageName.asp"> tag in the
    <head> section, created dynamicly based on the data returned!

  9. #9
    rao Guest

    Re: Getting Data Without Refreshing Page


    I don't think it is possible. May be possible if you use client record sets
    with RDS controls , personally i have not tried it .
    "Andy" <andy_boyd@yahoo.co.uk> wrote:
    >
    >Hi,
    >
    >Does anybody know if it is possible to retrieve data from a database and
    >update to the page without actually refreshing the whole page?
    >
    >As an example, say I have 10,000 people's name from the database listed

    in
    >a drop down combo box. I select a person from the drop down list, for which
    >I then use some script to put that persons age into a text field.
    >
    >My problem is that I have bandwidth limits (10,000 people's names, Ahhhh),
    >and so the solution is to enter the person’s name, and send this to the

    server
    >to let SQL Server get the age. But the only method I know how is to reload
    >the whole page again.
    >
    >Is there a method of executing some client script, which calls some server
    >script, which in turn passes data back to the client script, which can then
    >be populated into fields on the page?
    >
    >I welcome any ideas, suggestions, solutions.
    >
    >Thanks
    >



  10. #10
    Tushar Guest

    Re: Getting Data Without Refreshing Page


    I read all the answers here. I am using the xmlhttp object to do background
    requests. I thinks this is the simplest and fastest solution among the one's
    supplied. Also, one of the best things is until the data is actually retrieved
    the user can continue seeing the page and the new data appears so silently
    that the user may think he didn't see it for the first time.

    Implement this method it is simple, fast and made for xml, should you decide
    to move to xml later. I have already done. That is why.

    Tushar

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links