.ajax () "get" in .ajax () "get", ajax call now displays correctly

I have two ajax calls, but for some reason one of ajax does not work as planned.

one ajax call gets data from the site ajax1.php, and then another ajax gets data from ajax2.phpand it is supposed to change some data within ajax1.php.

So I have index.php, and ajax looks something like this:

This is index.php:

    $.ajax({
        type: "GET",
        data: "id="+id+"&id-other="+id-other,
        url: "ajax1.php"
    }).done(function(data){
        $("#div").html(data);

    });

    $.ajax({
        type: "GET",
        data: "id_1="+id+"&id_2="+id_2,
        url:"ajax/ajax2.php"
    }).done(function(data){
        $("#change_data").html(data);

    });

<div id="div">
<div id="change_data"><!-- This div is supposed to be in ajax1.php so it only appears after the first ajax is done.!--></div>
</div>

The problem is that #change_data is not displayed correctly. He shows what he needs for a second, then disappears. I don’t know what the problem is. I tried to put a delay: $("#change_data").delay.(1000).html(data_changed);like, but not working. I tried to put the whole ajax function inside the first .done () ajax function, but this will not work.

, - , , ajax , ajax. ajax , ?

? , , , ajax?

+3
2

, , ajax?

, :

$.ajax({
    type: "GET",
    data: "id="+id+"&id-other="+id-other,
    url: "ajax1.php"
}).done(function(data){
    $("#div").html(data);
    $.ajax({
        type: "GET",
        data: "id_1="+id+"&id_2="+id_2,
        url:"ajax/ajax2.php"
    }).done(function(data){
        $("#change_data").html(data);
    });
});
+8

$. ajax- , . , :

$.ajax({
        type: "GET",
        data: "id="+id+"&id-other="+id-other,
        url: "ajax1.php"
    }).done(function(data){
        $("#div").html(data);


        $.ajax({
           type: "GET",
           data: "id_1="+id+"&id_2="+id_2,
           url:"ajax/ajax2.php"
        }).done(function(data){
           $("#change_data").html(data);
        });

});
+3

All Articles