Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reload div after form submission success

Status
Not open for further replies.

cr84net2

Programmer
Feb 8, 2005
93
US
I have a classic asp site that is being partially updated to html5 and responsive design. There is a poll in an iframe that I am trying to move to a div. To do this I used
Code:
$.get('Poll/poll.asp', function(data) {
  $('#poll').html(data);
});

This loads the page/content into the div without issue. On the poll itself, I changed the action and method to onsubmit="return subpoll" .
I am serializing the form data successfully and submitting the form:
Code:
$(function subpoll() {
    //hang on event of form with id=formPoll
      $(document).on('submit', '#formPoll', function(e) {
        //prevent Default functionality
        e.preventDefault();

        //do your own request an handle the results
        $.ajax({
                url: 'Poll/poll.asp',
                type: 'post',
                dataType: 'json',
                data: $("#formPoll").serialize(),
                        
success: function(data){
   if(data.success == true){ // if true (1)
      $("#poll").load(" #poll > *");
}
}
});

    });
});
After I submit the form I have to refresh the page manually to see the results. I have tried many things in the data.success function without any luck. I need to reload the div with the poll results after successful submission. I am a novice with jquery/ajax/json so I may be missing something simple but I am beyond my abilities here. Poll/poll.asp submits to itself and shows the results as well. Any help would be appreciated. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top