0

I am injecting the following code into a specific page. The code refreshes a specific DIV class every 3 seconds without reloading the entire page.

jQuery(document).ready(function($) {
$.ajaxSetup({ cache: false });
setInterval(function() {
$('.activity-comments').load(location.href + ' .activity-comments')
}, 3000);
});

I would like to change this code so that it only refreshes the DIV class after a specific form is submitted (without reloading the entire page). Below are the details of the form:

<form class="comment-form" action="/comment/reply/111" method="post" id="comment-form" accept-charset="UTF-8">
<input type="submit" id="edit-submit" name="op" value="Comment" class="form-submit art-button ajax-processed">

I'm not sure if using .load is the most optimized method for doing this. How can I change my code to achieve this?

FrontEnd
  • 113
  • 4
  • Please take a look if it can help you. http://stackoverflow.com/questions/868890/ajax-how-refresh-div-after-submit#answer-869049 – b03Developer Oct 30 '14 at 12:57
  • I have tried to use the solution on that page but it doesn't refresh the div after submit. Below is my code: ``jQuery(document).ready(function($) { $("#comment-form").submit(function() { var options = { /* target:"#divResult", */ success: function(html) { $(".activity-comments").replaceWith($('.activity-comments', $(html))); }, url: location.href + ' .activity-comments' } $(this).ajaxSubmit(options); return false; }); });`` – FrontEnd Oct 30 '14 at 14:09

0 Answers0