two ajax request from one page

ajax, jquery, php

Solution

You've named them all the same. Try some consolidation

$(document).ready(function() {
    window.setInterval(function() { loadData('second.php', $('.hm_m_un')); }, 1000);
    window.setInterval(function() { loadData('test.php', $(".rx")); }, 1000);
});

var loadData = function(page, ele) {
    $.ajax({    
        type: "GET",
        url: page,             
        dataType: "html",                   
        success: function(response){                    
            ele.html(response); 
        }

    });
};

Problem

Simply I would like to load data from two php page using jquery. I put the below code together, however only the one works not both. Any ideas? ``` $(document).ready(function() { loadData(); }); var loadData = function() { $.ajax({ type: "GET", url: "second.php", dataType: "html", success: function(response){ $(".hm_m_un").html(response); setTimeout(loadData, 1000); } }); }; $(document).ready(function() { loadData(); }); var loadData = function() { $.ajax({ type: "GET", url: "test.php", dataType: "html", success: function(response){ $(".rx").html(response); setTimeout(loadData, 1000); } }); }; ```

Original source