After trying some solutions from this and many other questions I wasn't able to get what is exact problem in my code. My code
$('#genoffer').click(function(e){
e.preventDefault();
var offerstatus = $('#offerstatus').val();
if ($.trim(offerstatus) != '') {
$.ajax({
url:'general_create.php',
method: 'POST',
data:{offerstatus:offerstatus},
dataType: 'text',
success:function(data){
if ($.trim(data) == 'gsent') {
alert(data);
}else if($.trim(data) == 'agsent'){
alert(data);
}else{
alert(data);
}
}
});
}else{
alert('empty');
}
});
my script are given below
public function generalOfferLetter($offerstatus){
if ($offerstatus == 1) {
echo "gsent";
exit();
}elseif($offerstatus == 2){
echo "agsent";
exit();
}else{
echo "agsent";
}
}
It returns my expected result, but with result, it returns the HTML code of the whole page.
What is wrong in code?
general_create.php
$offerstatus = $_POST["offerstatus"];
$bookingsearch->generalOfferLetter($offerstatus);