hi, am trying to make ajax request to another page but I keep getting back my index/home page instead. please any idea(s)?
A little more information helps a lot on what it is your actually trying to do.
In the aspect of Ajax, you can load content into a page or sections of pages or load content that will be used by JS for other purposes etc...
For instance if you are trying to load content into a specific area on your page, you could do something like the following.
page 1 has a div that you want to load an external source's content into it
page 2 contains the external source's content in it.
Page1
< body>
<div id="load_external"></div>
< /body>
Page2
< body>
<div id="external_content">
< p>Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text < /p>
< p>Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text Just a bunch of text < /p>
</div>
< /body>
SCRIPT
$("#load_external").load("/page2.html #external_content",function(){});
It says when the page loads
- When you come across the DIV with the ID of
load_external
- Make a query/ajax request for the file "/page2.html"
- In page2.html specifically find the element with the ID of
external_content
- and insert into the DIV with the ID of
load_external
Saj