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?
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?
2 Answers
Reset to default 8If you want to have the items at first, its prepend, not append :-)
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'));