6

I have custom admin page edittab.phtml in that page I have ajax call

function deleteOldLens(id)
{
    var url = "<?php echo $this->getUrl('/customtabs/ajax/deletelens');?>";
    new Ajax.Request(url, {
        method:'post',
        parameters: {
            id: id
        }
        , requestHeaders: {Accept: 'application/json'},
        onSuccess: function(transport) {
            retjson = transport.responseText.evalJSON();
            alert( retjson.resp );
        }
    }); 
}

and in module customtabs/controllers/ajaxController.php I have deletelensAction().This code gives me error like

   http://localhost/optishop/index.php/admin/customtabs/ajax/key/c86e7acf7f7d45339bf50a7ab6efc4b2/?isAjax=true
   404 Not found

I have also tried other solutions like

  Mage::app()->getStore()->getUrl('*/ajax/deletelens');
  Mage::app()->getUrl('customtabs/ajax/deletelens')     
1
  • 2
    Please try var url = "<?php echo $this->getUrl('customtabs/ajax/deletelens/');?>"; (note the removal of the first /) Commented Dec 1, 2014 at 14:46

2 Answers 2

7

You should use

var url = "<?php echo
$this->getUrl('customtabs/ajax/deletelens/');?>";

Note the removal of the first /.

2

You can get controller url by

$this->getUrl('YourModulefontName/ajax/deletelens');
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.