Add test echo application
This commit is contained in:
parent
546e2ffe58
commit
87b671a21a
17
js/script.js
17
js/script.js
|
@ -0,0 +1,17 @@
|
||||||
|
jQuery(document).ready(() => {
|
||||||
|
jQuery("#submit").click(() => {
|
||||||
|
const text = jQuery("#text").val();
|
||||||
|
console.log("Sending:", text)
|
||||||
|
fetch(OC.generateUrl('/apps/upschooling/echo'), {
|
||||||
|
method: 'POST',
|
||||||
|
body: text,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
'requesttoken': oc_requesttoken,
|
||||||
|
},
|
||||||
|
}).then(async (res) => {
|
||||||
|
console.log(res);
|
||||||
|
jQuery("#response").val(await res.text());
|
||||||
|
}).catch(console.error)
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace OCA\UPschooling\Controller;
|
namespace OCA\UPschooling\Controller;
|
||||||
|
|
||||||
|
use OCP\AppFramework\Http\TextPlainResponse;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
|
@ -28,4 +29,8 @@ class PageController extends Controller {
|
||||||
return new TemplateResponse('upschooling', 'index'); // templates/index.php
|
return new TemplateResponse('upschooling', 'index'); // templates/index.php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function doEcho() {
|
||||||
|
return new DataResponse($_POST);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1,11 @@
|
||||||
<h1>Hello world</h1>
|
<h1>Hello world</h1>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<label for="text">Text to Send:</label><input type="text" id="text">
|
||||||
|
<button id="submit">Submit</button>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<label for="response">Response:</label>
|
||||||
|
<textarea id="response"></textarea>
|
||||||
|
|
Loading…
Reference in New Issue