无论如何都要同时使用负载和功能

时间:2012-10-11 11:57:45

标签: jquery

让我说我有这个html dom

<body>
  <div id="divId">
    <span>John,</span>
    <span>Karl,</span>
    <span>Brandon,</span>

    <span>Sam</span>
  </div>

我想在最后一个孩子之后 加载一个跨栏儿童 ,我想要这样的事情

$("#divId span:last-child").after().load('http://localhost/testing/getter.php');

如何使用加载功能后使用它

由于

2 个答案:

答案 0 :(得分:1)

您可以使用$.ajax

实现此目的
$.ajax({
    url: 'http://localhost/testing/getter.php',
    context: $('#divId')
}).done(function(data) {
    this.append(data);
});

在此处查看:http://jsfiddle.net/mfKvc/1/

答案 1 :(得分:0)

尝试以下方法:

$('<span>').load('http://localhost/testing/getter.php').insertAfter("#divId span:last-child");