0
下面是我的代碼,其中我有一個表單從哪裏用戶提交它,但我需要更新提交表單之前,少數數據,並將從user.Right採取現在我沒有添加輸入文本之前調用鏈接。提交onclick更好的建議
爲什麼在調用ajax後不提交表單可能是什麼原因?爲什麼不能這樣做? TIA
<script src="jquery-1.3.2.js" type="text/javascript"></script>
<script type="text/javascript">
function showConfirm() {
if(confirm('Are you sure?') == true){
//$("#testform").submit();
$("#showcall").show();
return false;
} else {
return false;
}
}
function secondFunction() {
$.ajax({
url: 'ajax_action.php',
success: function(data) {
//alert(data);
alert($("#testform").attr("method"));
$("#testform").submit();
//document.forms['myform'].submit();
}
});
}
</script>
<form action="action.php" method="post" enctype="multipart/form-data" id="testform">
<input type="text" name="name" id="name" />
<input type="submit" name="submit" id="submit" value="Go" onclick="return showConfirm();" />
<a href="javascript:;" onclick="secondFunction();" id="showcall" style="display:none;">Call</a>
</form>
這裏是我的action.php的
<?php
//echo 'working';
//echo '<pre>';
print_r($_POST);
?>
這裏是我的ajax_action.php
<?php
echo 'ajax called';
?>
這顯示了我的錯誤控制檯作爲 「document.testform.submit不是一個函數」。我已經嘗試過。反正thx隊友。 – Kamal 2012-03-22 14:27:55
是否將name屬性添加到表單元素中?你是否從文檔中調用相同的表單名稱? – eltuza 2012-03-23 01:06:54
耶夥伴我已經添加了相同的名稱「testform」,是的我把它稱爲document.testform.submit()。 – Kamal 2012-03-23 05:58:36