更新时间:2023-11-21 15:30:10
我在 joomla 中为 ajax 使用这种格式
I'm using this format for ajax in joomla
$.ajax({
type: 'GET',
url: 'index.php',
data: {option: 'com_componenetname', task: 'taskname.youroperation', format: 'json', tmpl: 'raw'},
dataType: 'json',
async: true, // can be false also
error: function(xhr, status, error) {
console.log("AJAX ERROR in taskToggleSuceess: ")
var err = eval("(" + xhr.responseText + ")");
console.log(err.Message);
},
success: function(response){
// on success do something
// use response.valuname for server's data
}
,
complete: function() {
// stop waiting if necessary
}
});
在您的组件/控制器中,您应该有一个文件 yourcontroller.json.php 它将处理您的调用并返回编码的 json 数组将您需要在客户端中的所有数据
In your component/controllers you should have a file yourcontroller.json.php which will process your call and return encoded json array will all the data you need in the client