Jump to content

How can I call the desired function via jquery?


Skyneuron

Recommended Posts

It is necessary that when you click on the button, a request is made via ajax and the desired row in the database is deleted.

I have the code:

$(".remove_order_submit").click(function(){
    $.ajax({
    url: "/modules/ps_customercedula/ps_customercedula.php",
    method: "post",
    data: {
        method: 1,
        id_order_remove: {$hook_name}
    },
    success: function(data){
        
    }
});
  });
});

How to write php so that if post method = 1 then call the function

public function displayAjax()
    {
        $db = \Db::getInstance();
        if ($this->errors)
            die(Tools::jsonEncode(array('hasError' => true, 'errors' => $this->errors)));

        if(Tools::getValue('method')=='1')
        {
            $db = \Db::getInstance();
            $result = $db->delete('log', 'id_log = 2');
        
        }
    }

 

Link to comment
Share on other sites

55 minutes ago, SmartDataSoft said:

Hello, you can check this post

 

 

You need to register the controller of the admin first , then follow this way

 

Thank you

<?php 
$link = new Link();
$urladmin = $link->getAdminLink( 'YourControllerName' );
?>
<script type="text/javascript">
var priceExpiryDate = "{$urladmin}";
</script>

This code is required. How to insert it into tpl correctly?

Link to comment
Share on other sites

9 minutes ago, SmartDataSoft said:

You can try this module which remove admin oder https://mypresta.eu/content/uploads/2020/02/deleteordersfree17.zip

 

https://mypresta.eu/modules/administration-tools/delete-orders-free.html

 

You need to add the js file from your module in back office header then call the admin controller from that function. 

 

THank you

He does not work. Please help with my question.

You can look at my code and tell me what is wrong. I've tried everything already.

deleteorders.rar

Edited by Motchanyy (see edit history)
Link to comment
Share on other sites

5 hours ago, SmartDataSoft said:

@Motchanyy

For you have add the code what is for adjust here is the final output. with image 

 

Do not forget to send me the final module when done vai PM :)

 

Thank you

ajax-call-oder.jpg

deleteorders.zip 26.62 kB · 3 downloads

Error

Have you checked the work of the module?

&& $this->CreateTabs() - there was an error when trying to update a module.

Edited by Motchanyy (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...