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') 
asked Dec 1, 2014 at 14:44
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 /.

answered Dec 1, 2014 at 15:14
2

You can get controller url by

$this->getUrl('YourModulefontName/ajax/deletelens');
answered Dec 1, 2014 at 14:46
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.