Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
164
rated 0 times [  167] [ 3]  / answers: 1 / hits: 25963  / 13 Years ago, mon, june 27, 2011, 12:00:00
 <script>   
$.ajax
({
url: ../getStatus/,
dataType: 'json',
success: function(json)
{
$('#ajaxLog').html(json.status+<br/>);
}
});

</script>

//Need this section to make a new line when refreshed
<div id = ajaxLog style=width:50%></div>


This needs to be an accumulative, returned message to the webpage. Each time the process starts/stop/suspends it will be displayed. The displayed message will not keep saying stopped/started/ etc. when remaining in a state - rather displayed each time these states change then it wont be redisplayed constantly -- NOT like jquery.append() does.



Desired



started 10:48
stoped 10:50
Started 12:53
suspended 3:34
Started 3:40


NOT DESIRED



started 10:48
started 10:48
started 10:48
started 10:48
started 10:48
started 10:48
started 10:48
stoped 10:50
.
.



and so on




(like append() would do)


More From » jquery

 Answers
5
    <script>   
//Use this
last=null;
$.ajax
({
url: ../getStatus/,
dataType: 'json',
success: function(json)
{
//Replace this line
//$('#ajaxLog').html(json.status+<br/>);

//with this:
if(last!=json.status)
{
$('#ajaxLog').append(json.status+<br/>);
//or: $('#ajaxLog').append('<p>'+json.status+'</p>');
last=json.status;
}
}
});

</script>

//Need this section to make a new line when refreshed
<div id = ajaxLog style=width:50%></div>

[#91481] Friday, June 24, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ignacio

Total Points: 467
Total Questions: 128
Total Answers: 79

Location: Luxembourg
Member since Tue, Mar 14, 2023
1 Year ago
;