Javascript uld可以更好地防止表单的默认提交,如果用户在表单内部按return该怎么办?它应该提交表单吗?请参阅一旦提交,ajax数据将再次返回表单,用户需要再次提交表单。为此,preventdefault不起作用您是否单击ajax加载的内容?是的,我正在再次单击a
Javascript uld可以更好地防止表单的默认提交,如果用户在表单内部按return该怎么办?它应该提交表单吗?请参阅一旦提交,ajax数据将再次返回表单,用户需要再次提交表单。为此,preventdefault不起作用您是否单击ajax加载的内容?是的,我正在再次单击a,javascript,php,jquery,ajax,forms,Javascript,Php,Jquery,Ajax,Forms,uld可以更好地防止表单的默认提交,如果用户在表单内部按return该怎么办?它应该提交表单吗?请参阅一旦提交,ajax数据将再次返回表单,用户需要再次提交表单。为此,preventdefault不起作用您是否单击ajax加载的内容?是的,我正在再次单击ajax加载的内容您可以更好地防止表单的默认提交,如果用户在表单内部按return怎么办?它应该提交表单吗?请参阅一旦提交,ajax数据将再次返回表单,用户需要再次提交表单。为此,preventdefault不起作用您是否单击ajax加载的内容?
uld可以更好地防止表单的默认提交,如果用户在表单内部按
return
该怎么办?它应该提交表单吗?请参阅一旦提交,ajax数据将再次返回表单,用户需要再次提交表单。为此,preventdefault不起作用您是否单击ajax加载的内容?是的,我正在再次单击ajax加载的内容您可以更好地防止表单的默认提交,如果用户在表单内部按return
怎么办?它应该提交表单吗?请参阅一旦提交,ajax数据将再次返回表单,用户需要再次提交表单。为此,preventdefault不起作用您是否单击ajax加载的内容?是的,我正在再次单击ajax加载的内容您可以更好地防止表单的默认提交,如果用户在表单内部按return
怎么办?它应该提交表单吗?请参阅一旦提交,ajax数据将再次返回表单,用户需要再次提交表单。为此,preventdefault不起作用您是否单击ajax加载的内容?是的,我正在再次单击ajax加载的内容您可以更好地防止表单的默认提交,如果用户在表单内部按return
怎么办?它应该提交表单吗?请参阅一旦提交,ajax数据将再次返回表单,用户需要再次提交表单。在我的例子中,我忘记传递事件
,也许你们在firefox上看到了这个问题,谢谢。问题也用你的解决方案解决了。简单紧凑。$(文档).ready(函数(e){/$('#sub_nav')。on('click',')。remove_item',function(event)$(“.quantity_box_button_up”)。click(函数(e){var abc=parseInt($(this).prev(“input”).val());$(this.prev(“input”).val(abc+1);$(“.quantity_box_button_down”)。click(函数(e){var bbc=parseInt($(this.next(“input”).val());alert(bbc);if(bbc==1){}else{$(this.next(“input”).val(bbc-1);}}});我在文本框中使用了这个jquery来增加和减少值。它工作正常,但对ajax数据不起作用。我尝试了您上面建议的方法,但对正常数据根本不起作用。很抱歉,在我的示例中,忘了传递事件
,也许您在firefox上看到了问题,谢谢。问题也用您的解决方案解决了。简单而有效impact.$(文档).ready(函数(e){/$('sub#u nav')。on('click','remove#item',函数(event)$(“.quantity#box(按钮)”)。click(函数(e){.var abc=parseInt($(this).prev($).val());$(this)。prev('input”).val(abc+1);$(.quantity#框(按钮)。)。click(函数(e){var bbc=parseInt($(this.next(“input”).val());alert(bbc);if(bbc==1){}else{$(this.next(“input”).val(bbc-1);}}});我在文本框中使用了这个jquery来增加和减少值。它工作正常,但对ajax数据不起作用。我尝试了您上面建议的方法,但对正常数据根本不起作用。很抱歉,在我的示例中,忘了传递事件
,也许您在firefox上看到了问题,谢谢。问题也用您的解决方案解决了。简单而有效impact.$(文档).ready(函数(e){/$('sub#u nav')。on('click','remove#item',函数(event)$(“.quantity#box(按钮)”)。click(函数(e){.var abc=parseInt($(this).prev($).val());$(this)。prev('input”).val(abc+1);$(.quantity#框(按钮)。)。click(函数(e){var bbc=parseInt($(this.next(“input”).val());alert(bbc);if(bbc==1){}else{$(this.next(“input”).val(bbc-1);}}});我在文本框中使用了这个jquery来增加和减少值。它工作正常,但对ajax数据不起作用。我尝试了您上面建议的方法,但对正常数据根本不起作用。很抱歉,在我的示例中,忘了传递事件
,也许您在firefox上看到了问题,谢谢。问题也用您的解决方案解决了。简单而有效impact.$(文档).ready(函数(e){/$('sub#u nav')。on('click','remove#item',函数(event)$(“.quantity#box(按钮)”)。click(函数(e){.var abc=parseInt($(this).prev($).val());$(this)。prev('input”).val(abc+1);$(.quantity#框(按钮)。)。click(函数(e){var bbc=parseInt($(this.next(“input”).val());alert(bbc);if(bbc==1){}else{$(this.next(“input”).val(bbc-1);}}});我有一个jquery,它可以在文本框中增加和减少值。它可以正常工作,但对ajax数据不起作用。我尝试了上面建议的方法,但对普通数据也不起作用
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</head>
<body>
<div id="abc">
<form action="abcd.php" method="post" accept-charset="utf-8" name="cartform">
<table cellpadding="6" cellspacing="1" style="width:100%" border="0">
<tr>
<th>QTY</th>
<th>Item Description</th>
<th style="text-align:right">Item Price</th>
<th style="text-align:right">Sub-Total</th>
</tr>
<input type="hidden" name="cartrowid[1]" value="d68b70f3503216b22484eef9c786124a" />
<tr>
<td><input type="text" name="cartrowqty[1]" value="1" maxlength="3" size="5" /></td>
<td> micromax_A12112
<p> <strong>Size:</strong> L<br />
<strong>Color:</strong> Red<br />
</p></td>
<td style="text-align:right">123.00</td>
<td style="text-align:right">$123.00</td>
</tr>
<input type="hidden" name="cartrowid[2]" value="e376db925db6430cf3e82c3854b4f5e2" />
<tr>
<td><input type="text" name="cartrowqty[2]" value="1" maxlength="3" size="5" /></td>
<td> Indian_Saree
<p> <strong>Size:</strong> L<br />
<strong>Color:</strong> Red<br />
</p></td>
<td style="text-align:right">2,555.00</td>
<td style="text-align:right">$2,555.00</td>
</tr>
</table>
<p>
<input type="submit" name="add_item_via_ajax_form" value="Update your Cart" class="add_item_via_ajax_form" />
</p>
</form>
<a href="http://w3schools.com/">Go to W3Schools.com</a>
<p>The preventDefault() method will prevent the link above from following the URL.</p>
</div>
</body>
</html>
<script>
$(function()
{
// Example of adding a item to the cart via a link.
$('.add_item_via_ajax_form').click(function(event)
{
alert(1);
event.preventDefault();
// Get the parent form.
var parent_form = $(this).closest('form');
// Get the url the ajax form data to be submitted to.
var submit_url = parent_form.attr('action');
// Get the form data.
var $form_inputs = parent_form.find(':input');
var form_data = {};
$form_inputs.each(function()
{
form_data[this.name] = $(this).val();
});
$.ajax(
{
url: submit_url,
type: 'POST',
data: form_data,
success:function(data)
{
//alert(data);
event.preventDefault();
ajax_update_mini_cart(data);
}
});
});
// A function to display updated ajax cart data from the mini cart menu.
function ajax_update_mini_cart(data)
{
$('#abc').html(data);
$('#mini_cart_status').show();
// Set the new height of the menu for animation purposes.
var min_cart_height = $('#mini_cart ul:first').height();
$('#mini_cart').attr('data-menu-height', min_cart_height);
$('#mini_cart').attr('class', 'js_nav_dropmenu');
// Scroll to the top of the page.
$('body').animate({'scrollTop':0}, 250, function()
{
// Notify the user that the cart has been updated by showing the mini cart.
$('#mini_cart ul:first').stop().animate({'height':min_cart_height}, 400).delay(3000).animate({'height':'0'}, 400, function()
{
$('#mini_cart_status').hide();
});
});
}
});
</script>
<script>
$(document).ready(function(){
$("a").click(function(event){
event.preventDefault();
});
});
</script>
//abcd.php
<form action="abcd.php" method="post" accept-charset="utf-8" name="cartform">
<table cellpadding="6" cellspacing="1" style="width:100%" border="0">
<tr>
<th>QTY</th>
<th>Item Description</th>
<th style="text-align:right">Item Price</th>
<th style="text-align:right">Sub-Total</th>
</tr>
<input type="hidden" name="cartrowid[1]" value="d68b70f3503216b22484eef9c786124a" />
<tr>
<td><input type="text" name="cartrowqty[1]" value="1" maxlength="3" size="5" /></td>
<td> micromax_A12112
<p> <strong>Size:</strong> L<br />
<strong>Color:</strong> Red<br />
</p></td>
<td style="text-align:right">123.00</td>
<td style="text-align:right">$123.00</td>
</tr>
<input type="hidden" name="cartrowid[2]" value="e376db925db6430cf3e82c3854b4f5e2" />
<tr>
<td><input type="text" name="cartrowqty[2]" value="1" maxlength="3" size="5" /></td>
<td> Indian_Saree
<p> <strong>Size:</strong> L<br />
<strong>Color:</strong> Red<br />
</p></td>
<td style="text-align:right">2,555.00</td>
<td style="text-align:right">$2,555.00</td>
</tr>
</table>
<p>
<input type="submit" name="add_item_via_ajax_form" value="Update your Cart" class="add_item_via_ajax_form" />
</p>
</form>
<a href="http://w3schools.com/">Go to W3Schools.com</a>
<p>The preventDefault() method will prevent the link above from following the URL.</p>
$('#abc').html(data);
$('.add_item_via_ajax_form').click(function(event) {}
function ajax_update_mini_cart(data) {}
$('#abc').html(data);
$('#abc').on('click', '.add_item_via_ajax_form', function(event){
//...
});