IC SunsetThe developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this community and its apps will no longer be available. More details available on our FAQ.
Topic
  • 4 replies
  • Latest Post - ‏2014-09-20T11:52:55Z by jitupkp
mahindra
mahindra
2 Posts

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

    Re: connecting database using AJAX

    ‏2011-09-08T17:48:18Z  
    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

    Re: connecting database using AJAX

    ‏2011-10-18T05:59:22Z  
    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
  • jitupkp
    jitupkp
    104 Posts

    Re: connecting database using AJAX

    ‏2014-09-20T11:52:34Z  

    get more help

    http://techgurulab.com/course/ajax-quiz-online/

  • jitupkp
    jitupkp
    104 Posts

    Re: connecting database using AJAX

    ‏2014-09-20T11:52:55Z  
    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/

    get more help

    http://techgurulab.com/course/ajax-quiz-online/