Results 1 to 3 of 3

Thread: Implementing Ajax with Prototype

  1. #1
    Join Date
    May 2009
    Posts
    223

    Implementing Ajax with Prototype

    Configuring your application

    The configuration steps are pretty basic, we will only have to declare our file including prototype.js in <head></head> in your application.
    Code:
     <script src="prototype.js" type="text/javascript"></script>
    After adding the library to your application and have all the functionality that it offers, such as $ () or $ F (), which is a fast version of $('id').value . So we collect data from our form in a very easy to implement.
    Code:
     var nombre=$F('nameUser'); var apellido=$F('surnameUser'); var direccion=$F('directionUser');

  2. #2
    Join Date
    May 2009
    Posts
    223

    Re: Implementing Ajax with Prototype

    Once collected all the items that need the merge all in a string to pass as parameters to the next page.
    Code:
    var param= 'name=' + nunber + '&surname=' + apellido + '&direction=' + direction;
    Once assembled and our parameters we lack the direction to which we send our parameters, and which we can recover the data.
    Code:
     var url = 'paginaReceptora.php';
    And now the call to the object that we perform the query using Ajax and we send the data to the page defined above.
    Code:
     var ajaxRequest = new Ajax.Request( url , { method: 'get', parameters: param , asynchronous: true, onComplete: showResponse }); function showResponse(xmlHttpRequest, responseHeader)
    As we can see in bold, have the 2 variables that we defined before as the value of tuna over onComplete send us the role showResponse as our Ajax request has returned any results. It is where we define the actions we want to perform once given the data, so here our imagination and our application rule.

  3. #3
    Join Date
    Feb 2011
    Posts
    40

    Re: Implementing Ajax with Prototype

    Prototype framework enables you to deal with Ajax calls in a very easy and fun way that is also safe (cross-browser). Besides simple requests, this module also deals in a smart way with JavaScript code returned from a server and provides helper classes for polling.

    Ajax functionality is contained in the global Ajax object. The transport for Ajax requests is xmlHttpRequest, with browser differences safely abstracted from the user. Actual requests are made by creating instances of the Ajax.Request object.

    new Ajax.Request('/some_url', { method:'get' });

    The first parameter is the URL of the request; the second is the options hash. The method option refers to the HTTP method to be used; default method is POST.

Similar Threads

  1. jQuery AJAX vs. Adobe AIR AJAX Class
    By Agaev in forum Windows Software
    Replies: 5
    Last Post: 06-07-2010, 01:59 PM
  2. Implementing forms with ASP
    By Dilbert in forum Software Development
    Replies: 4
    Last Post: 10-02-2010, 03:18 AM
  3. Implementing WIFI on a resort/bar
    By rogeryu in forum Technology & Internet
    Replies: 2
    Last Post: 22-01-2010, 05:18 PM
  4. Implementing rss on a site
    By Cruzz in forum Technology & Internet
    Replies: 5
    Last Post: 19-01-2010, 12:02 AM
  5. Implementing ADA on Xcode
    By Doroteo in forum Software Development
    Replies: 3
    Last Post: 19-11-2009, 06:22 AM

Tags for this Thread

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
  •  
Page generated in 1,713,242,219.78165 seconds with 16 queries