1

I do need to refresh a specicif div content, i've tried with .load

      $("#myDiv").load(location.href + " #myDiv");

And it works, but after that seems that I cannot manipulate the returned loaded 'div'. I checked and seems that the .load does not allow you to manipulate the returned code.

Is there any other way to refresh a div content without the .load?

Thanks a lot!

Ecoit
  • 19
  • 1
  • There is no other way to refresh content of a page without reloading unless you use AJAX. However, the issue you describe of not being able to manipulate the updated content is most likely because the event handlers bound to the original content were destroyed. You need to use delegated event handlers in that situation. See the duplicate for more information – Rory McCrossan Feb 15 '21 at 12:00
  • Thanks a lot Rory, maybe easier if I reload using ajax? i'll check documentation as I have no idea how. – Ecoit Feb 15 '21 at 12:29
  • You are already using AJAX - that's what `load()` does – Rory McCrossan Feb 15 '21 at 12:33
  • OK, thans a lot, so I need to the div be refreshed after a modal closes, so I've added the delegated event handlers as you said to the first instructions and then the .load but it seems that same behaivour. any other idea? maybe I need to add the .div too? $('#exampleModal').on('hidden.bs.modal', function () { $("#exampleId").load(location.href + " #exampleId"); – Ecoit Feb 15 '21 at 13:11
  • Without seeing the code it's impossible to diagnose the issue. I'd suggest starting a new question, but be sure to include all relevant code in it – Rory McCrossan Feb 15 '21 at 14:10

0 Answers0