I’ve been working with Sage the last two weeks and I find it very powerful, but as I’m new with Laravel/Blade there are some things that I don’t understand how to do.
I want to create a custom form which will call a 3rd party API. I’ve created a controller called Forms.php, the HTML form and the AJAX call in jQuery. How can I call the controller function in the ‘url’ parameter in the jQuery Ajax call?
In a normal Wordpress I would do a .php to handle the data (validation and send the data) and send a response back to Ajax ‘success’. What’s the best way to do that in Sage?
Thanks in advance for your help!
EDIT
Adding code for better understanding:
Common.js
$('form').submit(function(e){
e.preventDefault();
let url = // What to use here?,
data = $(this).closest('form').serialize();
$.ajax({
url: url,
type: 'post',
data: data,
success:function(response){
alert(response);
},
});
});
Form.php
namespace App\Controllers;
use Sober\Controller\Controller;
class Forms extends Controller
{
public function processForm()
{
return 'hello';
}
}