Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var vm = new Vue({
- el: '#app',
- data:{
- noticias: []
- },
- methods:{
- sync:function(){
- $.ajax({
- dataType: 'json',
- url: 'http://example/read.php',
- success:function(dados){
- localStorage.setItem('noticias',JSON.stringify(dados));
- vm.setNoticias();
- },
- error:function(){
- alert("ocorreu um erro durante a conexão com o servidor!");
- }
- });
- },
- setNoticias:function(){
- this.noticias = JSON.parse(localStorage.getItem('noticias'));
- console.log(this.noticias);
- }
- },
- ready:function(){
- this.setNoticias();
- }
- });
- vm.setNoticias();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement