Sunday, May 15, 2011

Soaps Without Betaine

AppFuse with Prototype Ajax Programming


Prototype, a JavaScript that implements the Ajax frameworks. Is object oriented, general purpose, ie can be used even in projects that involved no Ajax. Prototype

introduces an object called Ajax that, like all other objects and other functions seeks to eliminate the incompatibilities between browsers. In the case of Ajax, the XMLHttpRequest object differences between Mozilla Firefox and Microsoft ActiveX object in Internet Explorer. Internally, Prototype initializes an XMLHttpRequest object as follows:

 var Ajax = {
getTransport: function () {return
Try.these (
function () {return new XMLHttpRequest ()},
function () {return new ActiveXObject ('Msxml2.XMLHTTP ')},
function () {return new ActiveXObject (' Microsoft.XMLHTTP ')}
)

{method: 'get', parameters
'a = 1 & b = 2', onComplete
: funcionReceptora

});

 Request 
The method takes two arguments: the URL destination in which to settle the request (page, web service, flat file, etc.) and a series of data in JSON notation. Some of the possible are:


method: communication method (POST or GET).

parameters: parameters.

onComplete: function that is invoked when the transaction is complete.
asynchronous: asynchronous communication (true by default) or synchronous (false).

onSuccess: function to invoke when the transaction is completed successfully.
    onFailure: function to be invoked if there is a problem during the transaction.
  • evalScripts: true to evaluate JavaScript code of the response.
  • The function that takes control upon completion of the transaction (known as funcionReceptora) automatically takes the response as an argument:
  • funcionReceptora function (response) {
  • $ ('result'). InnerHTML = Respuesta.responseText;}
  • The answer admits the XMLHttpRequest object's properties, eg


responseText (response returned by the server).
 responseXML (response returned by the server validates as XML). 

status (response status).
statusText (description of the state).


This was a short summary of the use of Prototype
  • , leave links:
  • http://www.prototypejs.org/
  • http://api.prototypejs.org/

http : / / www.prototypejs.org / learn

0 comments:

Post a Comment