Unable To Access A Controller I Created

I created a controller with the code below:

shipping.php in addons\shipment_billing\controllers\backend\

<?php
use Tygh\Registry;
use Tygh\Settings;

if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }
if($mode == ‘edit_shipping’){
$shipping_id=$_POST[“shipping_id”];
$result = db_query('SELECT * FROM ?:order_shipment_billing WHERE id = ?s ', $shipping_id);
echo json_encode($response);
exit();

}

I created a button on the the order page in backend for accessing this controller for some existing data

tabs_content.post.tpl


The button is displaying but i am not able to pass the data to the controller to get the record back on the page. I dont want to create a submit button and refresh the whole order page so i wrote a JS function below.

{literal}



{/literal}

but it always gives me a error.

{current_url: "https://www.domain.com/secure.php?dispatch=shipping.edit_shipment", notifications: Array(0), text: ""}
current_url
:
"https://www.domain.com/secure.php?dispatch=shipping.edit_shipment"
notifications
:
[]
text
:
"     

404

↵ Page Not Found↵

The page you have requested cannot be found.

" __proto__ : Object

Also if i try to access the url directly it gives me 404 error.

https://www.domain.com/secure.php?dispatch=shipping.edit_shipment&shipping_id=690

I created a controller with the code below:

shipping.php in addons\shipment_billing\controllers\backend\

if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }
if($mode == ‘edit_shipping’){
$shipping_id=$_POST[“shipping_id”];
$result = db_query('SELECT * FROM ?:order_shipment_billing WHERE id = ?s ', $shipping_id);
echo json_encode($response);
exit();

}

I created a button on the the order page in backend for accessing this controller for some existing data

tabs_content.post.tpl


The button is displaying but i am not able to pass the data to the controller to get the record back on the page. I dont want to create a submit button and refresh the whole order page so i wrote a JS function below.

{literal}



{/literal}

but it always gives me a error.

{current_url: "https://www.domain.com/secure.php?dispatch=shipping.edit_shipment", notifications: Array(0), text: ""}
current_url
:
"https://www.domain.com/secure.php?dispatch=shipping.edit_shipment"
notifications
:
[]
text
:
"     

404

↵ Page Not Found↵

The page you have requested cannot be found.

" __proto__ : Object

Also if i try to access the url directly it gives me 404 error.

https://www.domain.com/secure.php?dispatch=shipping.edit_shipment&shipping_id=690

Hello!

Try to place your mode to the POST section:

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
}

404 error on the direct url occurs because you did not create the template for this page.

Note that the mode in js is edit_shipment, but edit_shipping in php

thanks guys it worked.