views:

54

answers:

2

I have a html page (index.html) which calls the ajax page(aj.php). The Ajax Page will return some number of <li>'s, like

<li>Blue Flower</li>
<li>White Assassin</li>

I already have some list items in the <ul> of the html page(index.html). When i try to append the result of the ajax page i.e.,<li>'s, it is appending at the last.

I want the <li>'s which returned from ajax page should be at first. How to achieve this. Please help. Any help will be appreciated

+6  A: 

If you want to have the items at first, its prepend, not append :-)

sod
+1  A: 

Are you looking for the .prependTo() function of jQuery? Docs are here.

So it'd be something like:

var returnedLIs = fromPHP;
$(returnedLIs).prependTo($('your ul'));
WSkid