Results 1 to 2 of 2

Thread: Passing a string to a function with web method...

  1. #1
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Passing a string to a function with web method...

    Hello!

    Can you help me?

    I've this situation:

    I use a web service through ajax. The service is "TreStringheService" and the web method is "GetTreStringhe", and that method accept one string parameter (in this case is 0100012).



    Code:
    <script language="javascript" type="text/javascript">
    
    function CallWebMethod()
    {
    TreStringheService.GetTreStringhe("0100012",Fill,ErrorHandler,TimeOutHandler);
    }
    
    function TimeOutHandler(result)
    {
    alert("Timeout :" + result);
    }
    
    function ErrorHandler(result)
    {
    var msg=result.get_exceptionType() + "\r\n";
    msg += result.get_message() + "\r\n";
    msg += result.get_stackTrace();
    alert(msg);
    }
    
    function Fill(result)
    {
    var lblMsg=document.getElementById("lblMsg");
    lblMsg.innerHTML = "TEST";
    }
    </script>
    
    <input type="button" önclick="CallWebMethod()" title="CLICCAMI" />



    Now, what i'll want is to passing to the Fill function a string parameter that is the element id, so i can say to the function the right element to use, for example:



    Code:
    <input type="button" önclick="CallWebMethod('lblMsg')" title="CLICCAMI"/>
    
    function CallWebMethod(elementID)
    {
    
    // but here? what i must write for passing the elementID string to the Fill function?
    TreStringheService.GetTreStringhe("0100012",Fill,ErrorHandler,TimeOutHandler);
    }
    
    // if i can passing a string to the Fill function i can do that
    
    
    
    function Fill(?????)
    {
    var lblMsg=document.getElementById(elementID);
    lblMsg.innerHTML = "TEST";
    }

    Pleeeeease help me! Thank u!!

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    ... OK... and the problem is?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •