mardi 14 juin 2016

Reload page after submit in iframe (javascript/jquery)


I have a page with an iframe. In the iframe there’s a submit button. When I click the submit button I want the parent window to be updated. This is what I have done so far, and it works (the javascript is located in the parent window):

var myFrame = $('iframe');
myFrame.load(function() {
myFrame.contents().find('#publish').click(function() {

  myFrame.load(function() {
    location.reload();
  });

});
});

The code works. But I find the reload of the iframe unnecessary. Is there a better way to detect when "submit" is completed?

(I can’t reload the page only by “onclick” or relay on any delay. I must be sure that the submitting of the form is finished)


Aucun commentaire:

Enregistrer un commentaire