首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jquery html(html_content)函数似乎在IE-7中不起作用

jquery html(html_content)函数似乎在IE-7中不起作用
EN

Stack Overflow用户
提问于 2012-10-10 20:48:47
回答 2查看 108关注 0票数 0

我有一个和ajaxsubmit方法,它的定义如下

代码语言:javascript
复制
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的组合)

检查成功回调中的数据后(如下所示)

代码语言:javascript
复制
<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中不起作用。

如果有人对此有任何想法,请告诉我。

谢谢,迪恩。

EN

回答 2

Stack Overflow用户

发布于 2012-10-10 20:55:19

尝试使用append而不是html

票数 0
EN

Stack Overflow用户

发布于 2012-10-10 21:00:29

根据rahul的回答,您可以通过jquery不断地选择相同的对象。当您在JQuery中执行操作时,它将返回受影响的对象,允许您链接您的操作。

例如:

代码语言:javascript
复制
$("td#argument_"+argument_id).removeClass("resource_automation_loader");
$("td#argument_"+argument_id).html(data[argument_id]).html(); 
$("td#argument_"+argument_id).html("<span></span>");

可以变成:

代码语言:javascript
复制
$("td#argument_"+argument_id).removeClass("resource_automation_loader")
                             .append(data[argument_id])
                             .append("<span></span>");

它只选择对象一次。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12819730

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档