AJAX Post错误,如没有$ _POST变量

时间:2018-05-18 15:46:36

标签: javascript php ajax post

我正在开发一个网站的一部分,它将textarea和输入文本的内容上传到远程数据库,但我在AJAX请求中遇到问题......

我的JavaScript:

Sub Macro11()
    Dim iRow As Integer

    For iRow = 9 To 50
        SolverOk SetCell:="$J" & iRow, MaxMinVal:=2, ValueOf:=0, ByChange:="$C" & iRow & ":$F" & iRow, _
            Engine:=1, EngineDesc:="GRG Nonlinear"
        SolverAdd CellRef:="$C" & iRow, Relation:=1, FormulaText:="23"
        SolverAdd CellRef:="$D" & iRow, Relation:=1, FormulaText:="23"
        SolverOk SetCell:="$J" & iRow, MaxMinVal:=2, ValueOf:=0, ByChange:="$C" & iRow & ":$F" & iRow, _
            Engine:=1, EngineDesc:="GRG Nonlinear"
        SolverOk SetCell:="$J" & iRow, MaxMinVal:=2, ValueOf:=0, ByChange:="$C" & iRow & ":$F" & iRow, _
            Engine:=1, EngineDesc:="GRG Nonlinear"
        SolverSolve
        SolverOk SetCell:="$J" & iRow, MaxMinVal:=2, ValueOf:=0, ByChange:="$C" & iRow & ":$F" & iRow, _
                Engine:=1, EngineDesc:="GRG Nonlinear"
    Next iRow
End Sub

我的salva_doc_ajax.php:

function pubblica(pubblicato){
  htmlpuro = document.getElementById("htmlpuro").value;
  oggetto = document.getElementById("oggetto").value;

  $.ajax({
    type: "POST",
    url: "salva_doc_ajax.php",
    data: "oggetto="+oggetto+"&html="+htmlpuro+"&pubblicato=0",
    dataType: "html",

    //Inizio visualizzazione errori
    success: function(msg)
    {
      alert(msg);
    },
    error: function()
    {
      alert("Chiamata fallita, si prega di riprovare...");
    }
  });
}

我在'htmlpure'和'oggetto'中测试了有数据...... 每次我运行这个js函数我从php页面得到“Errore”,就好像我不发送$ _POST变量......

1 个答案:

答案 0 :(得分:0)

我相信在ajax POST中,你的数据应该是一个对象。您正在为GET请求发送查询字符串。

另外,正如@Kaddath所说,你的帖子中没有名字。

通过将此行添加到driver.quit();的最顶部,并将其与您认为的结果进行比较,了解您所获得的内容:

salva_doc_ajax.php