OK , here is my issue;
My issue is that when i callback my php file with ajax it calls all the content of my file
here is my code
my source.php file which including my view.php file
<?php
if(isset($_POST['test'])){
echo "OK";
}
include_once "view.php";
?>
my view.php file
<!DOCTYPE html>
<html>
<head>
<title>Hello!</title>
</head>
<body>
<h1>Form</h1>
<form action="" method="post" id="form">
<input type="text" name="test" id="test" /><br>
<input type="submit" id="sub" name="sub" />
</form>
<div id="result"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#sub").click(function(){
$.ajax({
type: "POST",
data: $('#form').serialize(),
success: function(slider_data){
$("#result").text(slider_data);
}
});
return false;
});
});
</script>
</body>
</html>
Now when i submit my form my #result here is
OK<!DOCTYPE html>
<html>
<head>
<title>Hello!</title>
</head>
<body>
<h1>Form</h1>
<form action="" method="post" id="form">
<input type="text" name="test" id="test" /><br>
<input type="submit" id="sub" name="sub" />
</form>
<div id="result"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#sub").click(function(){
$.ajax({
type: "POST",
data: $('#form').serialize(),
success: function(slider_data){
$("#result").text(slider_data);
}
});
return false;
});
});
</script>
</body>
</html>
i want to show only the word "OK" or whatever i want and prevet sending all data and included file