Javascript image timout -


good day, i'm having problem code, can't show loading image few seconds, while post code getting in database , gives backinformation show.

$("#poll_vote").click(function(){  var answer = $("input.panswer:checked").val();  var p_id = $("#p_id").val();    $("#poll_load").html("<tr><td align='center'><img src='/images/ajax/ajax4.gif'/></td></tr>");      $.ajax({    type: "post",    data: "action=poll_vote&p_id="+p_id+"&answer="+answer+"&module="+module+"",    datatype: 'html',    url: "/ajax.php",    success: function(data)    {        $("#poll_content").html(data);      }    });      });

i hope on fast help, i'm begginer in java, can't dicide myself.

if want create delay loading animation shows (i believe is... mmm different, i'm going that...)

what need set timeout so:

settimeout(function(){ alert("hello"); }, 3000); 

now in code function contain ajax call:

$("#poll_vote").click(function(){ var answer = $("input.panswer:checked").val(); var p_id = $("#p_id").val();  $("#poll_load").html("<tr><td align='center'><img src='/images/ajax/ajax4.gif'/></td></tr>");  settimeout(function(){   $.ajax({     type: "post",     data: "action=poll_vote&p_id="+p_id+"&answer="+answer+"&module="+module+"",     datatype: 'html',     url: "/ajax.php",     success: function(data)     {         $("#poll_content").html(data);      }   }); }, 3000); }); 

or inside success function, believe better:

$("#poll_vote").click(function(){ var answer = $("input.panswer:checked").val(); var p_id = $("#p_id").val();  $("#poll_load").html("<tr><td align='center'><img src='/images/ajax/ajax4.gif'/></td></tr>");  $.ajax({   type: "post",   data: "action=poll_vote&p_id="+p_id+"&answer="+answer+"&module="+module+"",   datatype: 'html',   url: "/ajax.php",   success: function(data)   {        settimeout(function(){$("#poll_content").html(data);}, 3000, data);    } }); }); 

i didn't test it, check if in second case data can seen inside callback function (it should think...)

hope helps.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -