Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
163
rated 0 times [  168] [ 5]  / answers: 1 / hits: 8156  / 5 Years ago, sat, september 14, 2019, 12:00:00

I am trying with this JS:



        function refresh () { 
$.ajax({
url: window.location.href,
success: function(data) {
$('.torefreshdiv').html(data);
}
});
}


But this is loading the whole page inside the div, but i would like to refresh only the '.torefreshdiv'.

I thank everyone who helps me in advance.


More From » html

 Answers
7

You can create another resource for the content of the <div> to refresh (that can be another php script if using PHP, or the same script as the whole page but with some params...). Then:



function refresh () {
$.ajax({
url: '/div/to/refresh.php',
success: function(data) {
$('.torefreshdiv').html(data);
}
});
}

[#6248] Wednesday, September 11, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
angelr

Total Points: 399
Total Questions: 96
Total Answers: 101

Location: Finland
Member since Sun, May 21, 2023
1 Year ago
angelr questions
Tue, Sep 14, 21, 00:00, 3 Years ago
Mon, Dec 30, 19, 00:00, 4 Years ago
Sun, Jul 7, 19, 00:00, 5 Years ago
Mon, Dec 10, 18, 00:00, 6 Years ago
;