0

这是代码:

  $.ajax({
      url: 'AEWService.asmx/previewAsset',
      type: "GET",
      contentType: "application/json; charset=utf-8",
      data: json,
      success: function (json) {
          var prevObj = jQuery.parseJSON(json.d);
          setInterval(function () {
              var pId = $('#previewIframe').contents().find('[preview-id]');
              $.each(prevObj, function (i, item) {
                  pId.each(function () {
                      var pElem = this.attr("preview-id");
                      if (pElem == item.Id) {
                          $(this).html(item.Value);
                      }
                  });
              });
          }, 3000);
      }
  });
4

2 回答 2

5

this是一个 DOM 节点,而不是一个 jQuery 对象。请阅读.each()文档并查看示例。

实际上你似乎已经知道了,因为你打电话给$(this).html()......

于 2012-06-01T10:35:44.847 回答
1

尝试更改this.attr("preview-id")$(this).attr("preview-id")

就像你用这个$(this).html(item.Value)

希望这对您有所帮助。

于 2012-06-01T11:04:03.117 回答