开发者

Modify html via php

Hello I'm doing this to add a string after a div in an html page with jquery:

<a href="javascript:void(0);" onclick="PrependItemsToList();">Prepend items</a>   

<script type="开发者_如何学编程text/javascript">
function PrependItemsToList()
{       
    $("#content_gallery").prepend($("<li></li>").text("prepend() item"));

}
</script> 

Now I need to do it server side, any idea on how to implement it in php? I found phpquery but didn't find good docs about it.


So you're saying you want to do an AJAX call that returns HTML to be prepended to your content_gallery div?

<a class="prependLink" href="#">Prepend items</a>   

<script type="text/javascript">
function PrependItemsToList()
{       
    var url="yourpage.php";
    $.ajax(url, {
      success: function(data, textStatus, jqXHR){
        $("#content_gallery").prepend(data);
      });
    });
}

$('.prependLink').click(function(e){
  PrependItemsToList();
  e.preventDefault();
});

Of course, this approach is pointless if you aren't loading any information that isn't context-sensitive (ie. you pass some parameters to your remote page through your ajax call).

Posting more information will help us better answer your question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜