如果提交按钮是图像,则使用jQuery / AJAX提交的表单数据不会更新内容

我试图在div中显示AJAX响应。

如果我使用“提交”按钮,它会起作用,如果我将图像用作按钮,它就不起作用。

这是问题的工作示例

它似乎应该工作,因为它在代码中遇到相同的行并带回数据。 我已经花了大约8个小时没有运气。 任何帮助将不胜感激。

这是代码:

HTML:

    #editForm-1 input{float:left; margin:0 5px; padding:5px; border:1px solid red; } #editForm-1 .imgSubmit {margin:0; padding:0 10px; border:none;}    function performAjaxSubmission(formID) { var URL = "http://310it.com/test/updateDB-basic.php"; var formData = $("#editForm-" + formID).serialize(); $.post(URL , formData, function(theResponse){ alert("Data: " + theResponse + "\nStatus: " + status); $("#contentRight").html(theResponse); // $("#contentRight").text(theResponse); // This WORKS // document.getElementById("contentRight") = theResponse; // This does not work // document.getElementById("contentRight").innerHTML(theResponse); // This does not work }); }    

AJAX Response will be displayed here.

 

PHP:

 

我建议使用带图像标签的按钮而不是图像类型的输入; 后者有点儿麻烦。

更改:

  

至:

  

请享用 (: