403 Forbidden AJAX request in Magento 2
<p>I am using Magento 2 i want to send an AJAX request from my custom js. </p>

<p>Here is the code</p>

<pre><code>    jQuery.ajax({
    method: "POST",
    url: "app/code/Preview/Tag/Block/Baz/getTitle",
    data: {data: doc.output()},
}).done(function(data){
    console.log(data);
});
</code></pre>

<p>But it returns 403 forbidden. </p>

<p>Please let me know what is causing the issue.  </p>

<p>Controller code:</p>

<p>root_dir/app/code/Preview/Tag/Block/Baz.php</p>

<pre><code>    &lt;?php
namespace Preview\Tag\Block;

/**
* Baz block
*/
class Baz extends \Magento\Framework\View\Element\Template
{
    public function getTitle()
    {
        return "Foo Bar Baz";
    }
}

?&gt;
</code></pre>