以编程方式将 AJAX 中的 HTML 字符串加载到 Fancybox

Load HTML String from AJAX Into Fancybox Programmatically

我试图在 Fancybox 3 中以编程方式显示 HTML 字符串,但出现以下错误:'无法在 'Window' 上执行 'getComputedStyle':参数 1 不是输入 'Element'.

我曾尝试将类型更改为 'Inline' 并使用 href,但没有成功。 我还尝试在没有额外的 GetHTML 变量的情况下将内容更改为数据。

我看了这个 post,但运气不好: JS: Failed to execute 'getComputedStyle' on 'Window': parameter is not of type 'Element'

我也看过这个post: Loading dynamic AJAX content into Fancybox

$('.LinkFancybox').on('click', function () {
  var CategoryID = $(this).attr("id");
  var UserID = "<%=CurrentUserId%>";
  var CompanyID = "<%=CompanyID%>";
  var CurrentCustomerCode = "<%=CurrentCustomerCode%>";

if (CurrentCustomerCode == "") {
  CurrentCustomerCode = "000-000";
}

var APIURL = $.fn.GetBaseURL() + 'DesktopModules/DNNCommon/API/Store/GetProductsForPubCat?CategoryId=' + CategoryID + '&UserID=' + UserID + '&CompanyID=' + CompanyID;

$.ajax({
  type: "GET",
  async: true,
  url: APIURL,
  datatype: "json",
  success: function (data) {
  var GetHTML = data;
  $.fancybox.open({
  type: 'ajax',
  width: 800,
  height: 800,
  autoSize: false,                         
  content: GetHTML
});
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.responseText);
}
});
});

如果您希望显示HTML内容,则内容类型应为html,例如,更改为type: 'html'