Retrieve multiple values using ajax

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • galdunne
    New Member
    • Mar 2008
    • 1

    Retrieve multiple values using ajax

    Hi,

    Im new to ajax and im using prototype for a project i am working on. I am hoping to call a servlet written in java which holds a hashtable to strings. When i click on a link it opens up a tab - i want to auto insert the valuse held in the hastable into 7 textboxes. Is there a way to do this? I cannot figure out!!!!

    Here is the javascript function i have comp up with so far!


    [CODE=javascript] function showConfigurati on(){
    alert('configur ing the server!!');

    new Ajax.Request('s ervlet/Properties',
    {
    method:'POST',
    onSuccess: function(){
    Hashtable<Strin g,String> properties = Properties.getP roperties();
    document.getEle mentById("host" ).value = "test";
    document.getEle mentById("chann el").value = "test";
    document.getEle mentById("queue ").value = "test";
    document.getEle mentById("port" ).value = "test";
    document.getEle mentById("manag erName").value = "test";
    document.getEle mentById("usern ame").value = "test";
    document.getEle mentById("passw ord").value = "test";
    },
    onFailure: function(){
    alert('Failure' );
    }
    });
    }
    [/CODE]


    The "test" text above should hold the values pulled back from the servlet.

    I would really appreciate any help anyone could give me

    Thanks
    Last edited by gits; Mar 3 '08, 04:41 PM. Reason: added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Return the values in a format that can be used in JavaScript, e.g. XML, JSON, HTML or even text separated by a delimiter, e.g. "|". Then parse that with JavaScript.

    Comment

    Working...