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
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:
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.
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 > *");
}
}
});
});
});