Answer the question
In order to leave comments, you need to log in
How to implement an AJAX request?
I am writing a plugin for CMS Zencart and have come to a dead end.
I need to send an AJAX request to the current page.
I have two files in php
require('includes/application_top.php');
require('includes/mymodule/myModule.php');
//тут остальной код, но не в нем суть
$("input[name='syncProducts']").click(function(event) {
var myData={};
myData['action'] = "sync";
$.ajax({
url:ajaxURL,
type:"post",
data: myData,
dataType:"json",
success: function(data){
console.log(data);
}
});
});
if(isset($_POST['action']) && !empty($_POST['action'])) {
$dolibarr = Dolibarr::getInstance();
$action = $_POST['action'];
switch($action) {
case 'connect' :
break;
case 'sync' : $dolibarr->syncProducts();
break;
}
die();
}
class Dolibarr{
//тут сам класс
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question