I have a module that I need to do a php GET action and get some informations from php file. The problem is that the returned value is the Dashboard html.



namespace PereiraTech\Faturamento\Controller\Adminhtml\Ac;

use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;

class Index extends \Magento\Backend\App\Action

    protected $resultPageFactory;
    public $_storeManager;

    public function __construct(
        \Magento\Backend\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory,

        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory

    ) {
        $this->resultPageFactory = $resultPageFactory;    
        $this->resultJsonFactory = $resultJsonFactory;


     * Load the page defined in view/adminhtml/layout/exampleadminnewpage_helloworld_index.xml
     * @return \Magento\Framework\View\Result\Page
    public function execute()

        $params = $this->getRequest()->getParams();

        //Send response to Ajax query
        $data = 200;
        $result = $this->resultJsonFactory->create();
        return $result->setData($data);



## Heading ##define([      
], function ($,uiRegistry, select, modal) {
    'use strict';

    return select.extend({

    action: function(){            
            var ajaxRequest;
            ajaxRequest = jQuery.ajax({
                url: "faturamento_fat/Ac/Index",
                type: 'GET',
                data: {id : 1, form_key: window.FORM_KEY}, //exemple
                beforeSend: function () {

                //Show successfully for submit message
            ajaxRequest.done(function (response, textStatus, jqXHR) {

                //On failure of request this function will be called
            ajaxRequest.fail(function (xhr, status, error) {
                //show error
            return this._super();


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="admin">
        <route id="faturamento_fat" frontName="faturamento_fat">
            <module name="PereiraTech_Faturamento"/>
  • use url: "/faturamento_fat/Ac/Index", in ajax URL. Adding slash (/) before URL will add URI after baseUrl. – Shoaib Munir Apr 13 at 4:14
  • Tried, but received 404 error – Murilo Pereira Apr 13 at 11:53
  • browser URLs are case sensitive, may be you need to use all with small letter "/faturamento_fat/ac/index" – Shoaib Munir Apr 13 at 19:29
  • Tried too, but now I receive the dashboard's html, I've tried to post to one page that I know that worked, and received it html – Murilo Pereira Apr 13 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.