[英]Submit form (and disable button) in dynamically added content
我有一個單頁設計,在其中設置一個主div來保存並顯示當前的“頁面”內容(使用jquery)
然后我有一個js文件:
$(document).on("submit", "#kontaktform", function(){
$theform = $(this);
$.ajax({
url: "kontakt_val.php",
type: "POST",
cache: false,
timeout: 5000,
data: $theform.serialize(),
success: function(data) {
if (!data OR data=="ok") {
// AJAX ERROR OR OK: Continue to php validation
$("input[type=submit]",$theform).attr("disabled", "disabled");
$theform.unbind("submit").submit();
} else {
$("#jserrors").html('<p class="error">' + data + '</p>');
$("#jserrors").slideDown(150);
}
},
error: function(e) {
// AJAX ERROR: continue to php validation
$("input[type=submit]", $theform).attr("disabled", "disabled");
$theform.unbind("submit").submit();
}
});
return false;
});
$ theform.unbind(“ submit”)。submit(); 似乎沒有提交表格
我在想,這是因為表單的內容是隨js / jquery動態添加的
如何解決這個問題?
這似乎可行:
document.forms["kontaktform"].submit();
雖然不知道該怎么做
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.