我想在Opencart管理面板中使用ajax请求获取一些数据。我只是创建了一个控制器,它只返回json格式的数据。使用以下代码:
$.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']);
}
}
});有没有人能告诉我这是否正确,或者Opencart中是否有针对ajax请求的其他内置功能?这样我就可以继续在我剩下的页面中实现它了。
谢谢
发布于 2016-08-04 15:51:08
$.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")
}); https://stackoverflow.com/questions/37123632
复制相似问题