File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -53,17 +53,21 @@ <h4>Add To Do</h4>
53
53
54
54
function showTodos ( data , status ) {
55
55
$ ( "#todo_list" ) . empty ( ) ;
56
- $ . each ( data , function ( i , val ) {
57
- $ ( "#todo_list" ) . append ( i + " " + val + " <span id='todo" + i + "'>Remove<br>" ) ;
58
- $ ( "#todo" + i ) . css ( buttonCSS ) ;
59
- $ ( "#todo" + i ) . click ( function ( ) {
60
- $ . ajax ( {
61
- url : "http://localhost:8080/todos/" + i ,
62
- method : "DELETE" ,
63
- success : showTodos
64
- } )
65
- } ) ;
66
- } ) ;
56
+ if ( $ . isEmptyObject ( data ) ) {
57
+ $ ( "#todo_list" ) . append ( "<h4>You have nothing to do!</h4>" ) ;
58
+ } else {
59
+ $ . each ( data , function ( i , val ) {
60
+ $ ( "#todo_list" ) . append ( i + " " + val + " <span id='todo" + i + "'>Remove<br>" ) ;
61
+ $ ( "#todo" + i ) . css ( buttonCSS ) ;
62
+ $ ( "#todo" + i ) . click ( function ( ) {
63
+ $ . ajax ( {
64
+ url : "http://localhost:8080/todos/" + i ,
65
+ method : "DELETE" ,
66
+ success : showTodos
67
+ } )
68
+ } ) ;
69
+ } ) ;
70
+ }
67
71
}
68
72
} ) ;
69
73
</ script >
You can’t perform that action at this time.
0 commit comments