Topic
2 replies Latest Post - ‏2011-10-18T05:59:22Z by zabalex
mahindra
mahindra
2 Posts
ACCEPTED ANSWER

Pinned topic connecting database using AJAX

‏2011-09-08T12:53:55Z |
Hi all

I need to establish connection to remote database from my html page using

AJAX to display data dynamically.
Is it possible?
Updated on 2011-10-18T05:59:22Z at 2011-10-18T05:59:22Z by zabalex
  • SystemAdmin
    SystemAdmin
    1140 Posts
    ACCEPTED ANSWER

    Re: connecting database using AJAX

    ‏2011-09-08T17:48:18Z  in response to mahindra
    Make a Ajax request to a server method using a Servlet or a managed bean (with a JSF).
    http://www.ibm.com/developerworks/data/library/techarticle/dm-0701vohra/
  • zabalex
    zabalex
    2 Posts
    ACCEPTED ANSWER

    Re: connecting database using AJAX

    ‏2011-10-18T05:59:22Z  in response to mahindra
    Hi

    First create a function of java script in html page
    then create a blank div tag with an id

    var div = document.getElementById(divid);

    Then run code below:

    $.ajax({
    type: 'GET',
    url: 'page.aspx?CustId=' + CustId,
    data: 'page=' + CustId,
    success: function (data) {

    // Verify that we're pointed to a page that returned the expected results.
    if (data.indexOf('divresult') < 0) {

    $(div).html('<span >Page did not return a valid result for person ');
    }

    // Verify requested person is this person since we could have multiple ajax
    // requests out if the server is taking a while.
    //if (data.indexOf(UserID) > 0) {
    var text = $(data).find('#divresult').html();
    $(div).html("
    " + text + "
    ");
    //}
    }
    });
    By the above example you can hit the page and get the html of other page for display inside current page div.

    Thanks & Regards

    zabalex

    SEO San Francisco