English 中文(简体)
J Query Append AJAX
原标题:JQuery Append AJAX

I am using the following script to load some Wordpress posts. Unfortunately this replaces my content and I would like to append to the existing content.

你们关于使用美国宇宙航空研究开发机构的呼吁来评估的建议是什么。

$( #load-posts a ).click(function() { 
    if(pageNum <= max) {
        $( #content ).load(nextLink +   article ,
            function() {            
                // Update page number and nextLink.
                // Update the button message.                   
                }
            }
        );          
    }
});

成就

最佳回答

负荷取代母体的内容。 这样做的一种方式是将内容装到新的零件中,而不是把它用在要素上。

$("<div>").load(nextLink +   article , function() {
    $("#content").append($(this).html());
});
问题回答

load() replaces the content, but it s basically just a shortcut for $.get, so use that instead.

$( #load-posts a ).click(function() { 
    if(pageNum <= max) {
        $.get(nextLink +   article , function(data) {   
           $( #content ).append(data);
        });
    }
});

如果过滤装满负荷的具体元素,你必须做这项工作。

我将使用SerJson方法,在有3个部分的情况下,采用JSON对策。 1 PateNumber, 1 P-5, 1 P-4, 1 P-3, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 P-2, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 1 GS, 然后,一读JsonResult,并在相关地方使用。

你们可以回过来。

{
    "Content": "<p>Some New Content</p>",
    "NextLink": "page.php?no=34",
    "PageNumber": "34"
}

可在<条码>上读取。

$( #load-posts a ).click(function() { 
   if(pageNum <= max) {
      $.getJSON(nextLink,function(jSonResult){         
          $( #content ).append(jSonResult.Content);
          $("#nextLink").html(jSonResult.NextLink);
          $("#pageNumber").html(jSonResult.PageNumber);
      });           
   }
});
if(pageNum <= max) {
        $( body ).append($( <div id="hiddenContainer" style="display:none"></div> )); // a hidden container to store response
        $( #hiddenContainer ).load(nextLink +   article ,
            function() {            
                $( #content ).append($( #hiddenContainer ).html());                 
                }
            }
        );          
    }

个人使用$.get()

$( #load-posts a ).click(function() { 
    if(pageNum <= max) {
        var nextArticles = $.get(nextLink +   article )

        nextArticles.success(function() {
            // Update page number and nextLink.
            // Update the button message. 
        };
    }
});

从你的声音来看,你只是想加上新的职位信息,再补充如下现有的四点:

<div id="Posts">
  <!-- post -->
  <!-- post -->  
  <!-- post -->  
</div>

你们只能做:

jQuery( #Posts ).append(jQuery( <div> ).load(...));




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签