mahmooda
mahmooda

Reputation: 11

Page refresh without reloading a page and calling external files in php ajax

I have a profile page where im showing the friends of that user from db, I'm using auto scroller that works fine if I place that data directly in main file not an external file, Also I have a drop down that on selection will sort the friends records accordingly, but as I have moved the code to main file, I need to make ajax call to same file not an external, to repopulate data with required sorting.

Please let me know how can i do this on same file with ajax. On selection of drop down value.

Upvotes: 1

Views: 685

Answers (2)

José Valente
José Valente

Reputation: 331

Have you considered using Jquery?

Its surprisingly easy. You just need to do $('#contentdiv').load('contentyouwant') where you bind the event for the ddl.

Upvotes: 1

Nightwolf
Nightwolf

Reputation: 951

If you must use the same file, place the code that will be ran by ajax, in a function. then at the beginning of the page, evaluate if this was the ajax call or the whole file.

Hope it helps.

Upvotes: 0

Related Questions