0

i am calling to ajax, when the user entered the data in input, but it constantly returns 404 status

my code on my phtml file

<script>
    $j(document).ready(function(){
        var typingTimer;                //timer identifier
        var doneTypingInterval = 1000;  //time in ms, 5 second for example
        $j('#revision').keyup(function(){
            clearTimeout(typingTimer);
            if ($j('#revision').val) {
                typingTimer = setTimeout(function(){
                    //do stuff here e.g ajax call etc....
                    var valueRevision = $j("#revision").val();
                             <?php $ajaxUrl = Mage::helper('adminhtml')->getUrl('*/*/returnAjaxRevisionAction');?>
                     $j.ajax({
                         url: "<?php echo $ajaxUrl; ?>",
                         type: "POST",
                         data: JSON.stringify({"value": valueRevision}),
                         dataType : 'json',
                         cache: false,
                         success: function(data) {
                             console.log("SUCCESS: ", data);
                         },
                         error: function(data) {
                             console.log('ERROR: ', data);
                         }
                     });
                }, doneTypingInterval);
            }
        });
    });
</script>

code on my controller

 protected function _isAllowed()
    {
        return true;
    }

  public function returnAjaxRevisionAction(){
        var_dump('here');
        exit;
    }

my config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <DaniilKrok_Testing>
            <version>0.1.0</version>
        </DaniilKrok_Testing>
    </modules>
    <global>
        <helpers>
            <testing>
                <class>DaniilKrok_Testing_Helper</class>
            </testing>
        </helpers>
        <blocks>
            <testing>
                <class>DaniilKrok_Testing_Block</class>
            </testing>
        </blocks>
        <models>
            <testing>
                <class>DaniilKrok_Testing_Model</class>
                <resourceModel>testing_resource</resourceModel>
            </testing>
            <testing_resource>
                <class>DaniilKrok_Testing_Model_Resource</class>
                <entities>
                    <testing>
                        <table>dk_testing_data</table>
                    </testing>
                    <results>
                        <table>dk_testing_results</table>
                    </results>
                    <settings>
                        <table>dk_testing_settings</table>
                    </settings>
                </entities>
            </testing_resource>
        </models>
        <resources>
            <testing_setup>
                <setup>
                    <module>DaniilKrok_Testing</module>
                </setup>
            </testing_setup>
        </resources>
    </global>
    <admin>
        <routers>
            <testing>
                <use>admin</use>
                <args>
                    <module>DaniilKrok_Testing</module>
                    <frontName>testing</frontName>
                </args>
            </testing>
            <adminhtml>
                <args>
                    <modules>
                        <DaniilKrok_Testing before="Mage_Adminhtml">DaniilKrok_Testing</DaniilKrok_Testing>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

    <adminhtml>
        <layout>
            <updates>
                <testing>
                    <file>testing.xml</file>
                </testing>
            </updates>
        </layout>
    </adminhtml>
</config>
  • 1
    Try this getUrl('*/*/returnAjaxRevision') – pontikos Nov 2 at 12:39

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.