令人惊讶的stackoverflows。我有一个表单,通过ajax执行动态表单值的计算。表单输入值被提交,而跨度div值没有。有人能帮我吗。感谢
<script type="text/javascript">
$(document).ready(function (e) {
$("#orderForm").on('submit',(function(e) {
e.preventDefault();
$.ajax({
url: "order.php",
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData:false,
success: function(data)
{
$("#target").html(data);
$('#alerts').delay(2000).fadeOut('slow');
},
error: function()
{
}
});
}));
});
</script>
<form method="post" id="orderForm">
price:<input type="text" name="price[]" value=""><br>
sum total: <span id="sum">500</span>
</form>
答案 0 :(得分:0)
除了跨度之外,尝试向表单添加隐藏的输入字段。 像这样:
<form method="post" id="orderForm">
<input type="hidden" id="sum">
price:<input type="text" name="price[]" value=""><br>
sum total: <span id="sum">500</span>
</form>