Uzma Abdul Rasheed
Uzma Abdul Rasheed

Reputation: 60

How to refresh div content in jquery

I have this code:

$('#example').load(window.location.pathname+'#example');

after ajax call in success, but it is loading whole page in a div.

Any help would be appreciated.

Upvotes: 0

Views: 4681

Answers (2)

Sajad Deyargaroo
Sajad Deyargaroo

Reputation: 1149

The code to load the div is fine.

You need to look into the content returned by url. It seem window.location.pathname+'#example' returns the whole page.

Upvotes: -1

Jeff B
Jeff B

Reputation: 30099

Try adding a space:

$('#example').load(window.location.pathname+' #example');

According to the documentation example, there should be a space before the selector:

http://api.jquery.com/load/#loading-page-fragments

Upvotes: 5

Related Questions