Finally I've got a solution for the problem, by using the following script to run the PHP file. It seems that I had to import the JQuery from google-apis and use {literal} before and after my script.
Here is the updated javascript:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
{literal}
<script type="text/javascript">
function setStatus(order_id_sent)
{
var selectedIndex = document.getElementById("statusSelect").selectedIndex;
// test
// alert(document.getElementsByTagName("option")[selectedIndex].value + " " + order_id_sent);
var data = document.getElementsByTagName("option")[selectedIndex].value + "-" + order_id_sent;
$.ajax({
data: data,
type: "post",
url: "setStatus.php>",
success: function(data){
alert("data sent" + data);
}
});
}
</script>
{/literal}
And here is my PHP file, which is not complete yet but the point was to run the query and now it works properly.
<?php
include_once('../../../../../config/config.inc.php');
include_once('../../../../../init.php');
include_once('../../../../../classes/Db.php');
if(isset($_REQUEST))
{
error_reporting(E_ALL && ~E_NOTICE);
$words = explode('-', $_POST['data']);
//add code to update db
}
?>
0
down vote
accept
Finally I've got a solution for the problem, by using the following script to run the PHP file. It seems that I had to import the JQuery from google-apis and use {literal} before and after my script.
Here is the updated javascript:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
{literal}
<script type="text/javascript">
function setStatus(order_id_sent)
{
var selectedIndex = document.getElementById("statusSelect").selectedIndex;
// test
// alert(document.getElementsByTagName("option")[selectedIndex].value + " " + order_id_sent);
var data = document.getElementsByTagName("option")[selectedIndex].value + "-" + order_id_sent;
$.ajax({
data: data,
type: "post",
url: "setStatus.php>",
success: function(data){
alert("data sent" + data);
}
});
}
</script>
{/literal}
And here is my PHP file, which is not complete yet but the point was to run the query and now it works properly.
<?php
include_once('../../../../../config/config.inc.php');
include_once('../../../../../init.php');
include_once('../../../../../classes/Db.php');
if(isset($_REQUEST))
{
error_reporting(E_ALL && ~E_NOTICE);
$words = explode('-', $_POST['data']);
//add code to update db
}
?>