简体   繁体   中英

Multiple jQuery.ajax and data

Hello i'm doing a application in php, and i have a list of items that they have a list of another items inside. So i have a code for load the first list of items, but the idea is that the another items inside could be load by ajax:

function cargar(ids) {
  jQuery.ajax({
    url: "index.php?controller=descripcion&id=ids",
    dataType: "HTML",
    type: "POST",
    start: document.getElementById('orden_descripcion').innerHTML = '... Cargando',
    success: function(datos) {                      
      //document.getElementById('orden_descripcion').innerHTML = datos;
      $('#data-1').html(datos);
      $('#data-1').html(datos);

The idea is charge a lot of jQuery ajax in each #data-#, but i want to that the "datos" will be different, repect a var ids (my controller will be procces that id for different data), but i don't know how do this.

Thank you.

Well, i put in the nested list a javascript function like:

            <div id="orden-<var_id>">
                    <script type="text/javascript">     
                        cargar(<var_id>);       
                    </script>       
            </div>

Note: There is a lot of that orden-# divs, because is a list in a data base.

So that function is a jQuery.ajax function where the shows different type of data.

    <script type="text/javascript">
        function cargar(var_id) {
            jQuery.ajax({
                url: "index.php?controller=orden",
                data: "var_id="+var_id,
                dataType: "HTML",
                type: "POST",
                success: function(datos) {
                    $('#orden-'+var_id).html(datos);                
                }
            });
        }
    </script>

Thank you so much!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM