Today, I am here to talk about the use of the MooTools JavaScript library with Joomla Ajax, because it is a library, so do not have to have jquery, then how to achieve it, first set up an AJAX access button, generally we are in the editing of components used, So the file is generally in views\ your view \tmpl\default.php inside:
Copy Code code as follows:
<input type= "button" id= "Ajaxbutton" value= "Get Mode"/>
<div id= "Someid" ></div>
$doc =& jfactory::getdocument ();
$script = <<<script
Window.addevent (' Domready ', function () {
$ (' Ajaxbutton '). Addevent (' click ', function () {
New Ajax (
' Index.php?option=com_category&controller=category&task=aj&format=ajax ',
{
Method: ' Get ',
Update: ' Someid '
}
). request ();
});
});
SCRIPT;
Input this line is a Get Ajax button, followed by the display of the div layer return data, the following is the use of Ajax MooTools code, simply, here is through the GetDocument class method to add JS to the document head, note here $ is to represent the MooTools class library, ajax inside the URL parameter first is the component name, controller name, the implementation of the method AJ, this is written in the controller, is a click after the implementation of the method, you need to write back data, and finally return data type, this must be Ajax, otherwise the entire document will be returned, We're here as long as the AJ method returns the data section. There are two parameters, get is the way to obtain data, Someid is the binding return data display ID, this is necessary.
Ajax use is not necessary, but sometimes have to use, if the use of the original ecology, I would like to load or quickly, MooTools library I have not used, just suit, here is to provide a way to achieve Ajax, how to implement the Post method, You just need to add the appropriate form elements. Here I do not say much, because the use is not a lot. OK, here, don't provide examples, if you need to be able to see the editing form elements when you try the code or something is very short, copy it!