简体   繁体   English

Opencart-在管理面板中调用ajax请求的方法

[英]Opencart - Way to call ajax request in Admin Panel

I want to fetch some data using ajax request in Opencart Admin panel. 我想在Opencart管理员面板中使用ajax请求获取一些数据。 I have simply created a controller which only returns data in json format. 我只是创建了一个仅以json格式返回数据的控制器。 Using below code: 使用以下代码:

$.ajax({
    type: 'post',
    url: 'index.php?route=common/ajaxdata/functionName&token=<?php echo $token; ?>',
    data: data,
    dataType: 'json',
    success: function(json) {
        if (json['success']) {
            alert(json['success']);
        }
    }
 });

Can anybody please let know whether this is correct or any other built in functionality available in Opencart for ajax requests? 有人可以告诉我这是正确的还是Opencart中针对ajax请求提供的其他任何内置功能? So that I can proceed and implement this in my rest of the pages. 这样我就可以在其余页面中继续执行此操作。

Thanks 谢谢

$.ajax({
    type: "POST",
    url: "http://your url write hare",
    contentType: "application/json",
    dataType: "json",
    data: JSON.stringify({
        "propertytypename": property,
        "propertytypecreatedby": property_name
    }),
    success: alert("success"),
    error: alert("Fail")

}); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM