每次我尝试提交表单时,它只返回“E”并且只返回“E”,我不知道为什么会这样,有人可以帮我解决这个问题吗?
我尝试了很多方法,但我不能;似乎没有得到它应该返回的结果
代码
查询:
$('#edit_ok_btn').click(function(e)
{
e.preventDefault();
$('#NoticeBox').hide("slide", { direction: "up" }, 500, function() {
$('#NoticeBox').show("slide", { direction: "up" }, 500);
$('#NoticeBox').removeClass()
$('#NoticeBox').addClass('Box_Working')
$('#noticeText').html("Processing page...");
var formData = $('#EditorForm').serialize();
submitWebPage(formData);
});
});
function submitWebPage(formData) {
$.ajax({
type: 'POST',
url: 'PageProcessor.php',
data : {'formdata' : formData},
dataType: 'json',
cache: false,
timeout: 7000,
success: function(data) {
$('#NoticeBox').hide("slide", { direction: "up" }, 500, function() {
if(data.error == false)
{
$('#NoticeBox').show("slide", { direction: "up" }, 500);
$('#NoticeBox').removeClass()
$('#NoticeBox').addClass('Box_Success')
$('#noticeText').html(data.msg);
$('#PageEditor').fadeOut(1000);
$('#NoticeBox').delay(1000).hide("slide", { direction: "up" }, 500, function() {
location.reload();
});
}
else
{
$('#NoticeBox').show("slide", { direction: "up" }, 500);
$('#NoticeBox').removeClass()
$('#NoticeBox').addClass('Box_Error')
$('#noticeText').html(data.error);
}
});
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$('#responder').removeClass().addClass('Box_Error').html('<p>There was an ERROR!<strong></p>');
}
});
PHP
$PageID = $_POST['formdata']['EditID'];
$PageTitle = $_POST['formdata']['PageTitle'];
$PageCategory = $_POST['formdata']['CategoryList'];
$PageContent = $_POST['formdata']['elm1'];
$PagePublished = $_POST['formdata']['PublishPageOption'];
if($PageID == "NEW")
{
mysqli_query("INSERT INTO Web_Pages (Title, HTML, Category, Last_Author, Edit_Date, Published) VALUES ('".$PageTitle."','". $PageContent."','".$PageCategory."','LUX','".date("Y-m-d")."','".$PagePublished."') ");
$return['error'] = false;
$return['msg'] = '<i>'.$PageTitle.'</i> has been created successfully.';
echo json_encode($return);
}
else
{
mysqli_query("UPDATE Web_Pages SET Title = '".$PageTitle."', HTML = '".$PageContent."', Category = '".$PageCategory."', Last_Author='LUX', Edit_Date = '".date("Y-m-d")."', Published = '".$PagePublished."') WHERE ID = '".$PageID."' ");
$return['error'] = false;
$return['msg'] = '<i>'.$PageTitle.'</i> has been updated successfully.';
echo json_encode($return);
}