I have an small app at:
/var/www/nextcloud/apps/test2
It has its own section at admin section when user can enter some values.
This section has a Javascript file
/var/www/nextcloud/apps/test2/js/adminsettings.js
I’d like to have a Javascript function “doit()” in “adminsettings.js” which should call a PHP “somefunc” -function in /var/www/nextcloud/apps/test2/lib/AppInfo/Application.php
function doit() {
var whaturl="what is the url to ..Application.php"
$.ajax({
method: 'POST',
url: whaturl ,
contentType: 'application/json',
data: JSON.stringify(test0),
success: function(messagesent) {
if (messagesent == 'success')
{ console.log("success"); }
else if (messagesent == 'failure') {
console.log('fail!'); }
},
error: function() {
alert('fail2');
}
}); }
How do I get the url to “/var/www/nextcloud/apps/test2/lib/AppInfo/Application.php” in my Javascript function and call “somefunc” there?
Here is the “/var/www/nextcloud/apps/test2/lib/AppInfo/Application.php”
<?php
declare(strict_types=1);
namespace OCA\test2\AppInfo;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Util;
use OCP\IUser;
class Application extends App implements IBootstrap {
public const APP_NAME = 'test2';
protected $appName;
public function __construct() {
parent::__construct(self::APP_NAME);
}
public function register(IRegistrationContext $context): void
{
}
public function boot(IBootContext $context): void
{
}
}
function somefunc() {
/* do something here */
}