how to push item in array in document.ready and onsucess of button click using jquery -


var selectedanswer; var qestionarray = []; var ansewrarray = [];  $(document).ready(function() {   qestionarray.push(@question.id)    selectedanswer = ($(':radio[name="dummy"]:checked').val());    $(':radio[name="dummy"]').on('click', function() {     selectedanswer = ($(':radio[name="dummy"]:checked').val());   });     $("#nextbtn").click(function() {      $.ajax({       url: "/user/getnextquestion",       type: "post",       data: {         id: @question.id       },       success: function(data) {         $("#loadquestion").html(data);         qestionarray.push(@question.id);/* not getting id of first question while loaded, else other ids getting*/         ansewrarray.push(selectedanswer);         if ($("#finish").click(function() {           $.ajax({             url: "/user/checkresult",             type: "post",             data: {               ans: ansewrarray,               quest: qestionarray             },             success: function(data) {}            });          }));        },       error: function() {         alert("error")        }     });   }); }); 

hello need add items on success of next button click..its working fine first items loaded on document.ready not coming...

please need help.... hello need add items on success of next button click..its working fine first items loaded on document.ready not coming...

please need help....


Comments