I am having request like this:
$(function(){
$("#novaProfaktura").click(function(){
$.ajax({
type: "POST",
url: "../Pages/Program.php",
data: { action: "testing" },
success: function()
{
alert("Ajax done"); //Testing purpose
}
});
location.reload();
});
});
And then in my body I have php like this:
<div id="Content">
<?php
echo("Php running <br>");
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
echo("Post running <br>");
if($_POST['action'] = "testing")
{
echo("Action running <br>");
}
}
?>
</div>
What I am getting from this is alert message
so I assume ajax is set up properly and getting Php running
but it doesn't pass if($_SERVER['REQUEST_METHOD'] == 'POST'
As you can see jQuery code is running on div click.
What am I doing wrong?
EDIT: I have used function(data)
and it seems to work BUT it doesn't return only echoed
data but WHOLE page with echo. I used document.write()
and it rewrite whole page but how to get particular echo value?