List several ul inside a li using AJAX

Asked

Viewed 375 times

0

How can I list varios ul within a li, dynamically, with AJAX?

Something like ul>li>ul>li>ul>li

The doubt arose because I’m making a linear network of a MMN system and I can’t dynamically load the ul after the first li.

  • 1

    You need to explain better what you want to do and what result you want. As well as some code you have tried.

  • the result I would like would be like this: https://www.dropbox.com/s/69zegxe72ko4kb8/Capturar.PNG?dl=0

  • You can generate your server-side content, or use data from a server outside of your control?

  • yes the system is already selecting the table in db and sending via json to ajax I want to see how to list this in html :S

  • Hi, Eduardo, instead of adding information here in the comments, click [Edit] and include these details in the question itself. I did not edit myself because it seems that the image has details of particular; if you can make a generic example.

1 answer

1

If I understand correctly, you want to dynamically place a <ul> within a <li> returned by AJAX and if I understood correctly want to do it with JQUERY. I put here an example that answers what I understood in the question.

html:

<ul id="teste">
    <li></li>
    <li></li>
</ul>

In the JQUERY:

$("ul#teste li").each(function () {
    var retorno_ajax = "<ul><li>sub-linha1</li><li>sub-linha2</li></ul>";
    $(this).html(retorno_ajax);
});

The each access dynamic content as well. Do not forget that the .html will delete the previous content and put the new one that for example results. However if you want to add the return to the existing content within the lithen use the append.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.