-1
提交時,下面的表單「查看此產品」將觸發此功能,該功能將獲得產品ID [form_data]並將作爲url參數與表單數據一起傳遞。我成功了,直到獲得form_data 但頁面沒有被重定向。文檔就緒功能停止重定向
我非常懷疑我的功能沒有正常結束。
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
<script>
$(document).ready(function(){
$(".form-item").submit(function(e){
var form_data = $(this).serialize();
var button_content = $(this).find('button[type=submit]');
window.location = "1stlink.php?variable=" + encodeURIComponent(form_data);
button_content.html('Adding...'); //Loading button text
});
});
提交表單:
<form class="form-item">
<input name="product_code" type="hidden" value="{$row["product_code"]}">
<button type="submit">view this product</button>
的頁面不重定向,因爲'e.preventDefault();'取消了'submit'事件。 –
'e.preventDefault();'這是停止重定向。 – rishipuri
嘗試使用不使用preventdefault以及仍然沒有進展..編輯刪除e.preventdefault bcos,不causong問題的問題 – prog