我有一个和ajaxsubmit方法,它的定义如下
var new_options = {
dataType: 'json',
beforeSubmit: function() {
alert('inside before submit');
$(".available_script_arguments").each(function(index) {
argument_id = $(this).val()
$("td#argument_"+argument_id).addClass("resource_automation_loader");
});
},
success: function(data) {
alert('inside success');
$(".available_script_arguments").each(function(index) {
argument_id = $(this).val()
$("td#argument_"+argument_id).removeClass("resource_automation_loader");
$("td#argument_"+argument_id).html(data[argument_id]).html();
$("td#argument_"+argument_id).html("<span></span>");
updateTargetArgumentId();
triggerAdapterResourceAutomation();
});
},
error: function(jqXHR, textStatus, errorThrown){
alert('inside error');
$(".resource_automation_loader").each(function(){
// This will hide the loader
$(this).removeClass("resource_automation_loader");
// This will display text N.A indicating the resource automation has failed
$(this).html("<input type='text' value='' placeholder='N.A'></input>");
});
}
};
$("form#update_resource_automation_parameters").ajaxSubmit(new_options);此函数在火狐中工作正常,但在IE7中不起作用。
我找出了原因,并在成功回调中使用了jquery html函数。
在成功的回调中,数据以html的形式出现( div和select的组合)
检查成功回调中的数据后(如下所示)
<div >
<select arg_val="null">
<option value="">Select</option>
<option value="0">Corporate Strategic</option>
<option value="1">Business Unit Strategic</option>
<option value="2">Maintenance</option>
<option value="3">Defect</option>
</select>
</div>因此,这些数据基本上输出到视图中的选择列表,但这在IE7中不起作用。
如果有人对此有任何想法,请告诉我。
谢谢,迪恩。
发布于 2012-10-10 20:55:19
尝试使用append而不是html
发布于 2012-10-10 21:00:29
根据rahul的回答,您可以通过jquery不断地选择相同的对象。当您在JQuery中执行操作时,它将返回受影响的对象,允许您链接您的操作。
例如:
$("td#argument_"+argument_id).removeClass("resource_automation_loader");
$("td#argument_"+argument_id).html(data[argument_id]).html();
$("td#argument_"+argument_id).html("<span></span>");可以变成:
$("td#argument_"+argument_id).removeClass("resource_automation_loader")
.append(data[argument_id])
.append("<span></span>");它只选择对象一次。
https://stackoverflow.com/questions/12819730
复制相似问题