I need to customize the button that is located on the service page. When clicked, it should transfer the service_id to another page and open immediately.
tamplate smarty
<a class="menuitm menu-auto" id="gotozabbixlist" ><span>Zabbix host list</span>
<input id="secretid" value="{php} echo $_REQUEST['id']; {/php}" type="hidden"/></a>
ajax
$('#gotozabbixlist').on('click', function (e) {
var $this = $(this);
let id = document.getElementById('secretid').value;
let url = 'http://www.website.com/bla/bla/zabbixhost.php';
$.ajax({
url: url ,
type: "POST",
data: {
someData: id
},
success: function (){
}
});
})
The file that accepts it zabbixhost.php
<?php
print_r($_POST);
I’ve been thinking about this for two days now.
2
Answers
I solved the problem in a different way. I just add "?id = 12323" to the url and then get it with "$service_id = $_REQUEST['id'];"
AJAX is used to make a background request … what you can do however have a submit button to the form and in the action of the form you have the route to the service page…