簡體   English   中英

來自$ .get的另一個頁面的jquery元素

[英]jquery element from another page with $.get

我正在嘗試從另一個具有id = usertags的頁面中提取元素。 我正在使用.get方法。

由於某種原因,我無法實現它,沒有錯誤。

$.get('/cgi-bin/koha/opac-tags.pl', function(data) {
    var tags = $(data).find("#usertags");
    $("#mainuserblock").append(tags);
    console.log( $(data) );
});

我對日志信息$(data)所說的感到困惑。 在我看來,它實際上並不是從opac-tags.pl頁面中拉出的,而是從其他地方拉出來的:

{
  "length": 0,
  "prevObject": {
    "0": {
      "auth": {
        "0": {
          "0": {},
          "1": {},
          "2": {},
          "3": {},
          "4": {}
        },
        "1": {
          "0": {},
          "1": {},
          "2": {},
          "3": {},
          "4": {},
          "5": {}
        }
      },
      "searchform": {
        "0": {
          "0": {},
          "1": {},
          "2": {},
          "3": {},
          "4": {},
          "5": {},
          "6": {}
        },
        "1": {},
        "2": {}
      },
      "location": {
        "href": "http://viu.bywatersolutions.com/cgi-bin/koha/opac-main.pl",
        "origin": "http://viu.bywatersolutions.com",
        "protocol": "http:",
        "host": "viu.bywatersolutions.com",
        "hostname": "viu.bywatersolutions.com",
        "port": "",
        "pathname": "/cgi-bin/koha/opac-main.pl",
        "search": "",
        "hash": ""
      }
    },
    "context": {
      "auth": {
        "0": {
          "0": {},
          "1": {},
          "2": {},
          "3": {},
          "4": {}
        },
        "1": {
          "0": {},
          "1": {},
          "2": {},
          "3": {},
          "4": {},
          "5": {}
        }
      },
      "searchform": {
        "0": {
          "0": {},
          "1": {},
          "2": {},
          "3": {},
          "4": {},
          "5": {},
          "6": {}
        },
        "1": {},
        "2": {}
      },
      "location": {
        "href": "http://viu.bywatersolutions.com/cgi-bin/koha/opac-main.pl",
        "origin": "http://viu.bywatersolutions.com",
        "protocol": "http:",
        "host": "viu.bywatersolutions.com",
        "hostname": "viu.bywatersolutions.com",
        "port": "",
        "pathname": "/cgi-bin/koha/opac-main.pl",
        "search": "",
        "hash": ""
      }
    },
    "length": 1
  },
  "context": {
    "auth": {
      "0": {
        "0": {},
        "1": {},
        "2": {},
        "3": {},
        "4": {}
      },
      "1": {
        "0": {},
        "1": {},
        "2": {},
        "3": {},
        "4": {},
        "5": {}
      }
    },
    "searchform": {
      "0": {
        "0": {},
        "1": {},
        "2": {},
        "3": {},
        "4": {},
        "5": {},
        "6": {}
      },
      "1": {},
      "2": {}
    },
    "location": {
      "href": "http://viu.bywatersolutions.com/cgi-bin/koha/opac-main.pl",
      "origin": "http://viu.bywatersolutions.com",
      "protocol": "http:",
      "host": "viu.bywatersolutions.com",
      "hostname": "viu.bywatersolutions.com",
      "port": "",
      "pathname": "/cgi-bin/koha/opac-main.pl",
      "search": "",
      "hash": ""
    }
  },
  "selector": "response = {\n\tadded: 0,\n\tdeleted: 0,\n\terrors: 0\n\n\n};"
}

有沒有人經歷過這樣的事情?

看到這個問題 ,尤其是這個答案

基本上,您應該將HTML上下文作為$的第二個參數傳遞:

$("#usertags", data);

另外,此語法也應起作用:

$("#mainuserblock").load("/cgi-bin/koha/opac-tags.pl #usertags");

但它將覆蓋#mainuserblock先前內容。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM