I have an html form that loads the main portion of a document, postload an ajax request goes off and gets an xml file that is parsed out to create 'sub' forms which can be updated/submitted. This is the form 'preload'
我有一个html表单加载文档的主要部分,postload ajax请求关闭并获取一个xml文件,解析出来创建可以更新/提交的“子”表单。这是“预加载”的形式
<html>
<head>
<script src="jquery.js">
<script src="jquery.forms.js">
<script>
$(document).ready(function () {
//Script to execute when form is loaded
loadOrder(unid);
});
</script>
</head>
<body>
<form id="mainform" name="main" method="post" action="whatever">
<input type="hidden" id="unid" name="unid" value="123" />
</form>
<div id="orderForms">
</div>
</body>
</html>
Here is the form post load :
这是表格后加载:
<html>...
<div id="orderForms">
<form id="order_1" name="order" method="post" action="whatever">
<input type="hidden" id="pid_1" name="pid" value="123" />
<input type="hidden" id="unid_1" name="unid" value="456" />
</form>
<form id="order_2" name="order" method="post" action="whatever">
<input type="hidden" id="pid_2" name="pid" value="123" />
<input type="hidden" id="unid_2" name="unid" value="789" />
</form>
</div>
</body>
</html>
JS code:
function loadOrders(unid){
var rUrl = "url";
$.ajax({type: "GET", url: rUrl, async: true, cache: false, dataType: "xml", success: postLoadOrders}) ;
}
function postLoadOrders(xml){
nxtOrder = 1;
var html="";
$('order',xml).each(function() {
// parses the xml and generates the html to be inserted into the <div>
});
$("#orderForms").html(html);
}
This all works, the main form loads, the 'hidden' forms in the <div>
are written in. The trouble happens when I put a button on the main form that does this...
这一切都有效,主要表单加载,
function submitOrder(){
$("#pid_1").val('555');
$("#order_1").formSerialize();
$("#order_1").ajaxSubmit();
}
If I alert($("#pid_1").val()) prior to the .val('555') it shows the original value, when I alert after, it shows the new value, however it submits the original value, and if I open the html in firebug the value isn't showing as changing.
如果我在.val('555')之前警告($(“#pid_1”)。val())它会显示原始值,当我提醒时,它会显示新值,但它会提交原始值,如果我在firebug中打开html,则值不会显示为更改。
If I put a hidden field into the main form, that exists when the document loads and change its value, not only does the new value post, it also shows as being changed when examining the source.
如果我将一个隐藏字段放入主窗体中,当文档加载并更改其值时存在,不仅新值发布,它还显示在检查源时更改。
Any ideas?
1 个解决方案
#1
0
$('order',xml).each(function() {
});
this is not Object in JQuery
这不是JQuery中的Object
You can edit:
你可以编辑:
$('[name=order]',xml).each(function() {
});
#1
0
$('order',xml).each(function() {
});
this is not Object in JQuery
这不是JQuery中的Object
You can edit:
你可以编辑:
$('[name=order]',xml).each(function() {
});