Advertisement
Guest User

Pedido Ajax View

a guest
Apr 20th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var interval;
  2.         var seconds = 30;
  3.         function MostrarPerguntaPorZona(lat, long, dif) {
  4.             $.ajax({
  5.                 url: '/Pergunta/GetRandomByZona',
  6.                 data: { latitude: lat, longitude: long, dificuldade: dif },
  7.                 datatype: "json",
  8.                 success: function (data) {
  9.                     $('#perguntaID').val(data.PerguntaId);
  10.                     $('#zonaNome').text(data.ZonaNome);
  11.                     $('#pergundaDescricao').text(data.Descricao);
  12.                     $('#Resposta1Descricao').text(data.Hipotese1Descricao);
  13.                     $('#Resposta2Descricao').text(data.Hipotese2Descricao);
  14.                     $('#Resposta3Descricao').text(data.Hipotese3Descricao);
  15.                     $('#Resposta4Descricao').text(data.Hipotese4Descricao);
  16.                     $("#PerguntaImagem").attr("src", data.Imagem);
  17.                     $("#AjudaPergunta").text(data.AjudaPergunta);
  18.                     /*if(data.Conq == 1)
  19.                         alert('Esta zona ja foi conquistada! Continua a explorar.');
  20.                     else {
  21.                         $('#myModal').modal('toggle');
  22.                     }*/
  23.                 }
  24.             });
  25.             $('#myModal').modal('toggle');
  26.             seconds = 30;
  27.             interval = setInterval(function () {
  28.            
  29.                 var el = $("#timer");
  30.                 if (seconds == 0) {
  31.                     clearInterval(interval);
  32.                     el.html('0:00');
  33.                     $('#myModal').modal('hide');
  34.                     seconds = 30;
  35.                 } else {
  36.                     seconds--;
  37.                     el.html(seconds);
  38.                 }
  39.             }, 1000);
  40.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement