每次我嘗試提交我的表單時,它只返回「E」,只返回「E」,我不知道爲什麼會發生這種情況,誰能幫我解決這個問題?jquery不會將數字傳遞給php
我已經嘗試了多種方法,我可以;噸似乎得到的結果應該返回
碼
的Jquery:
$('#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);
}
paste-bin link to the source code
請不要使用'mysql_'函數,因爲它們不再被維護並且正在被棄用。 Google,PDO或Mysqli代替 – samayo 2013-03-03 01:03:17
@PHPNooB,感謝您的提示,稍後我會對它進行一些研究! – LUX 2013-03-03 01:07:47
將更新sql命令複製到phpmyadmin中,放入實際值,並查看它是否可以在那裏使用。 – michi 2013-03-03 01:13:35