ajax在joomla中的原生態(tài)應(yīng)用代碼
Jun 13, 2016 am 11:59 AM
今天筆者在這里講一講使用joomla自帶的mootools javascript庫的實(shí)現(xiàn)ajax,由于是自帶庫,所以不用管有沒有jquery,那么怎么實(shí)現(xiàn)呢,首先建立一個(gè)ajax的獲取按鈕,一般我們都是在組件的編輯中用到,所以文件一般在views\你的視圖\tmpl\default.php里面:
復(fù)制代碼 代碼如下:
$doc =& JFactory::getDocument();
$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這一行是一個(gè)獲取ajax的按鈕,接著是顯示返回?cái)?shù)據(jù)的div層,下面就是使用ajax的mootools代碼,簡單說下,這里是通過getDocument類方法添加js到文檔head里面,注意這里$是代表mootools類庫,ajax里面的網(wǎng)址參數(shù)首先是組件名,控制器名,執(zhí)行的方法aj,這個(gè)寫在控制器里面,就是點(diǎn)擊后執(zhí)行的方法,需要寫返回?cái)?shù)據(jù),最后就是返回?cái)?shù)據(jù)類型,這里必須是ajax,否則會把整個(gè)文檔都返回,我們這里只要aj方法的返回?cái)?shù)據(jù)部分.有兩個(gè)參數(shù),get是獲取數(shù)據(jù)方式,someID是綁定的返回?cái)?shù)據(jù)顯示id,這都是必須的.
ajax使用不是必須的,但是有時(shí)候不得不用,如果使用原生態(tài)的,我想加載還是很快的,mootools庫筆者也沒有用過,只是照貓畫虎,這里畢竟是提供了一種實(shí)現(xiàn)ajax的方法,怎么實(shí)現(xiàn)POST方法呢,只需要添加相應(yīng)表單元素即可.在這里筆者就不多說了,因?yàn)橛玫牟皇呛芏?好了,就講到這里,就不提供例子了,如果你需要可以在遇到編輯表單元素時(shí)候試試代碼什么的都很短,copy一下就好了!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Build an autocomplete suggestion engine using PHP and Ajax: Server-side script: handles Ajax requests and returns suggestions (autocomplete.php). Client script: Send Ajax request and display suggestions (autocomplete.js). Practical case: Include script in HTML page and specify search-input element identifier.

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

Cloud storage has become an indispensable part of our daily life and work nowadays. As one of the leading cloud storage services in China, Baidu Netdisk has won the favor of a large number of users with its powerful storage functions, efficient transmission speed and convenient operation experience. And whether you want to back up important files, share information, watch videos online, or listen to music, Baidu Cloud Disk can meet your needs. However, many users may not understand the specific use method of Baidu Netdisk app, so this tutorial will introduce in detail how to use Baidu Netdisk app. Users who are still confused can follow this article to learn more. ! How to use Baidu Cloud Network Disk: 1. Installation First, when downloading and installing Baidu Cloud software, please select the custom installation option.

NetEase Mailbox, as an email address widely used by Chinese netizens, has always won the trust of users with its stable and efficient services. NetEase Mailbox Master is an email software specially created for mobile phone users. It greatly simplifies the process of sending and receiving emails and makes our email processing more convenient. So how to use NetEase Mailbox Master, and what specific functions it has. Below, the editor of this site will give you a detailed introduction, hoping to help you! First, you can search and download the NetEase Mailbox Master app in the mobile app store. Search for "NetEase Mailbox Master" in App Store or Baidu Mobile Assistant, and then follow the prompts to install it. After the download and installation is completed, we open the NetEase email account and log in. The login interface is as shown below

Deleted something important from your home screen and trying to get it back? You can put app icons back on the screen in a variety of ways. We have discussed all the methods you can follow and put the app icon back on the home screen. How to Undo Remove from Home Screen in iPhone As we mentioned before, there are several ways to restore this change on iPhone. Method 1 – Replace App Icon in App Library You can place an app icon on your home screen directly from the App Library. Step 1 – Swipe sideways to find all apps in the app library. Step 2 – Find the app icon you deleted earlier. Step 3 – Simply drag the app icon from the main library to the correct location on the home screen. This is the application diagram

Xiaomi car software provides remote car control functions, allowing users to remotely control the vehicle through mobile phones or computers, such as opening and closing the vehicle's doors and windows, starting the engine, controlling the vehicle's air conditioner and audio, etc. The following is the use and content of this software, let's learn about it together . Comprehensive list of Xiaomi Auto app functions and usage methods 1. The Xiaomi Auto app was launched on the Apple AppStore on March 25, and can now be downloaded from the app store on Android phones; Car purchase: Learn about the core highlights and technical parameters of Xiaomi Auto, and make an appointment for a test drive. Configure and order your Xiaomi car, and support online processing of car pickup to-do items. 3. Community: Understand Xiaomi Auto brand information, exchange car experience, and share wonderful car life; 4. Car control: The mobile phone is the remote control, remote control, real-time security, easy

As a programmer, I get excited about tools that simplify the coding experience. With the help of artificial intelligence tools, we can generate demo code and make necessary modifications as per the requirement. The newly introduced Copilot tool in Visual Studio Code allows us to create AI-generated code with natural language chat interactions. By explaining functionality, we can better understand the meaning of existing code. How to use Copilot to generate code? To get started, we first need to get the latest PowerPlatformTools extension. To achieve this, you need to go to the extension page, search for "PowerPlatformTool" and click the Install button

The role and practical application of arrow symbols in PHP In PHP, the arrow symbol (->) is usually used to access the properties and methods of objects. Objects are one of the basic concepts of object-oriented programming (OOP) in PHP. In actual development, arrow symbols play an important role in operating objects. This article will introduce the role and practical application of arrow symbols, and provide specific code examples to help readers better understand. 1. The role of the arrow symbol to access the properties of an object. The arrow symbol can be used to access the properties of an object. When we instantiate a pair
