Advertisement
Guest User

Untitled

a guest
Nov 27th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. var vm = new Vue({
  2. el: '#app',
  3. data:{
  4. noticias: []
  5. },
  6. methods:{
  7. sync:function(){
  8. $.ajax({
  9. dataType: 'json',
  10. url: 'http://example/read.php',
  11. success:function(dados){
  12. localStorage.setItem('noticias',JSON.stringify(dados));
  13. vm.setNoticias();
  14. },
  15. error:function(){
  16. alert("ocorreu um erro durante a conexão com o servidor!");
  17. }
  18. });
  19. },
  20. setNoticias:function(){
  21. this.noticias = JSON.parse(localStorage.getItem('noticias'));
  22. console.log(this.noticias);
  23. }
  24. },
  25. ready:function(){
  26. this.setNoticias();
  27. }
  28. });
  29.  
  30. vm.setNoticias();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement