所以我有这样的jQuery:jQuery的AJAX POST没有将数据传递到PHP脚本
$("#dropbin").droppable(
{
accept: '#dragme',
hoverClass: "drag-enter",
drop: function(event)
{
var noteid = "<?=isset($_POST['noteid']) ? $_POST['noteid'] : "" ?>";
if (confirm('Delete the note?')==true)
{
$('#dragme').hide();
debugger
$.ajax({
type: 'POST',
data: noteid,
datatype: 'json',
url: 'deleteNote.php',
success: function(result)
{
alert("Success");
}
});
window.location = "http://discovertheplanet.net/general_notes.php";
}
else
{
window.location = "http://discovertheplanet.net/general_notes.php";
}
}
});
,并包括此网址:url: 'deleteNote.php',
:
<?php
include "connectionDetails.php";
?>
<?php
if (isset($_POST['noteid']))
{
// $noteid2 = $_POST['noteid1'];
echo "You finally hit this bit, congratulations...";
// $stmt = "UPDATE Notes SET Deleted = GETDATE() WHERE NoteID = (?)";
// $params = $noteid2;
// $stmt = sqlsrv_query($conn, $stmt, $params);
// if ($stmt === false)
// {
// die(print_r(sqlsrv_errors(), true));
// }
}
else
{
echo "No Data";
}
?>
现在即使在URL中运行/deleteNote.php?noteid=25它也会触发我的PHP的“无数据”部分。
当我在调试程序中运行时,它用NoteID填充变量noteid,以便该位可以工作,但PHP文件说它没有设置?
当您运行'/deleteNote.php?noteid = 25'时,它将运行“no data”,因为这是一个GET设置,而不是您的代码正在寻找的POST。 – IsThisJavascript
你是否收到警报(“成功”);顺便一提? – IsThisJavascript
是的,我得到了成功的警报,编辑:我也试过GET以及我不知道,并没有返回任何数据 –