this is not my first time to use ajax on my website but right now im really confused whats wrong with it. i even removed the important codes. what im doing right now. is to check if ajax is passing the data to the php or not.
<script type='text/javascript'>
$(document).ready(function () {
$('.btndeclineme').click(function () {
var docreason = document.getElementById("docreason");
if (docreason !== null && docreason.value === "")
{
$('#reasonalert').show();
return;
}else{
var signatoryidglobal = JSON.parse('<?php echo json_encode($_SESSION['signatoryid']); ?>');
alert(signatoryidglobal);
$('#reasonalert').hide();
$.ajax({
type: "POST",
url: "sample.php",
data: ({dtsignatory: signatoryidglobal})
})
.done(function (msg) {
alert( "Data:" + msg);
})
.fail(function() {
alert( "Posting failed." );
});
};
});
});
</script>
and this is the sample.php
<?php
$temp1 = $_POST['dtsignatory'];
echo $temp1;
?>
my problem is its not showing errors. isn't it supposed to promp the data i passed to the php because of alert( "Data:" + msg); but it keeps showing nothing.
i even add a alert prompt to check if the variable has a value. and it has a value. sorry for my bad english. i hope my question is clear
$.ajax({
type: "POST",
url: "sample.php",
data: {
dtsignatory: signatoryidglobal
},
headers: {
"Accept": "application/json; charset=utf-8"
},
contentType: "application/json; charset=utf-8",
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.