Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Send AJAX Request Using YAHOO User Interface Library?

    • 0
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 149
    Comment on it

    If you want to send ajax request using yahoo user interface library, for that follow the below mentioned code step by step.

    First Import Yahoo libraries in page you want to access them

    1. Include namespace echo (reference path)
      YAHOO.namespace("echo");
    1. Calling a function in script

    2. YAHOO.echo.addField.field_lookup(this)
      here addField refers to the prototype class and field_lookup refers to the function which is called on the following event.

    3. field_lookup function and ajax request handling

    4. YAHOO.echo.addField = {
          field_lookup: function(s){
      // Callback for ajax request
              var callback = {
                  success: function(o){
                  //When ajax request successful do the job
                      YAHOO.echo.refreshPanel(o.responseText);
                  },
                  failure: function(o){
                  //When ajax request failure do some job
                      alert('Unable to connect to server.');
                  },
                  cache: false
              }
      
      //URL for ajax request
                var url = 'mypage.php?_fn=View&id=' + s.getAttribute("data");
      //Send ajax request
                  YAHOO.util.Connect.asyncRequest('GET', url, callback);
              }
          };
      //Ajax request success function
      YAHOO.echo.refreshPanel = function(contents){
      // Use the response code
      alert(contents);
          }
      

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: