簡體   English   中英

使用Ajax,php將數據插入數據庫時​​出錯

[英]Error while inserting data into database using with ajax,php

使用ajax,php和jquery將數據插入數據庫時​​出錯,適用於localhost,但在上載到服務器后會出錯。

$('#sunsubmit').click(function(){
    var insertedvalue = $('#sundayform').serialize();
    $('form#sundayform').unbind('sunsubmit');
    $.ajax({
        type: "POST",
        url: "routineinsert/sunday.php",
        data: insertedvalue,
        beforeSend: function(messageinfo){},
        success: function(messageinfo){ 
            var c = customalertbox.render("Message!!",messageinfo);
            progressdiv.style.display="none";},
        error: function(jqxhr) {
            customalertbox.render(jqxhr.responseText);
        }
});

它可以在我的計算機上正常工作,但是對於服務器,即使它沒有重定向到插入代碼所在的星期日文件,它也直接調用錯誤函數。

您的成功功能似乎缺少左括號:

success: function(messageinfo) 

它應該是

success: function(messageinfo) {

如果您始終對格式保持謹慎,這將更容易注意到:

    success: function(messageinfo)  <============
        var c = customalertbox.render("Message!!",messageinfo);
        progressdiv.style.display="none";
    },
    error: function(jqxhr) {
        customalertbox.render(jqxhr.responseText);
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM