Skip to content

Instantly share code, notes, and snippets.

@PeterTheOne
Created May 15, 2013 16:05
Show Gist options
  • Save PeterTheOne/5585124 to your computer and use it in GitHub Desktop.
Save PeterTheOne/5585124 to your computer and use it in GitHub Desktop.
How to Execute a scheduler task via an ajax request to an eID in typo3... TYPO3 version 4.5.16
<?php
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
$GLOBALS['TSFE']->fe_user = tslib_eidtools::initFeUser();
tslib_eidtools::connectDB();
if(t3lib_div::_POST('wsproductlist') || t3lib_div::_GET('wsproductlist')){
$get = t3lib_div::_POST('wsproductlist');
if($get == '') {
$get = t3lib_div::_GET('wsproductlist');
}
switch ($get[action]) {
case 'executeScheduler':
echo json_encode(executeScheduler());
break;
}
}
// doesn't seem to work
function executeScheduler() {
/* @var tx_scheduler */
$tx_scheduler = t3lib_div::makeInstance('tx_scheduler');
$task = $tx_scheduler->fetchTasksWithCondition('classname = ..._customer', true);
return $tx_scheduler->executeTask($task);
}
?>
...
$.ajax({
url: 'index.php',
type: 'POST',
data: {
eID: '..._eID',
'wsproductlist\[action\]': 'executeScheduler'
},
// Es hat funktioniert?
success:function (response) {
console.log(response);
alert('Successfully updated');
},
// Schade, es war ein Fehler
error :function (error) {
console.log(error);
}
});
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment