1

每次我尝试提交表单时,它只返回“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);
}

paste-bin 链接到源代码

4

2 回答 2

2

您有一个不应该存在)的查询接近尾声,很可能是您忘记编辑的复制/粘贴/编辑的结果。UPDATE

于 2013-03-03T01:04:11.123 回答
0

我厌倦了这个错误!

 data: 'formData',

这现在将被视为字符串而不是变量

我想你应该做这样的事情

data : {'formdata' : formData}

从php你可以得到数据

$_POST['formdata'];
于 2013-03-03T02:21:37.240 回答