doflamingo doflamingo - 4 years ago 131
Ajax Question

jquery ajax - why .load() cannot load self page?

I try to refresh some

in my page with ajax load by using
but not work. I have to create new file page that use php to echo my div again. So Question is Do I have to create new file for echo that div, if I just want to refresh some div in my page?


above is not work.

I have to use below code.


Answer Source

Use Ajax for this.

Build a function that will fetch the current page via ajax, but not the whole page, just the div in question from the server. The data will then (again via jQuery) be put inside the same div in question and replace old content with new one.

Relevant function:


$('#thisdiv').load(document.URL +  ' #thisdiv');

Note, load automatically replaces content. Be sure to include a space before the hastag.

Reference link : Refresh Part of Page (div)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download