2

I am using the JQuery load functionality to load content of one page into another. My main page (index.html) has a div tag with id 'abcd'. I need to load contents of another page (page1.html) into the div tag specified. So, I write the following code :-

$('#abcd').load('page1.html?title=xyz','',function(){})

Note that I am also passing parameter 'title=xyz' alongwith the URL of the page to load. I need to get this parameter and work with it in page1.html content. How can I fetch this in page1.html page?

3
  • html not run on server side, use php Commented Nov 23, 2012 at 5:49
  • Hi I am able to load contents of page1.html but not able to access the parameters. Commented Nov 23, 2012 at 6:47
  • which parametrs you wnat to access ? you have that parameters at the moment you make the url Commented Nov 23, 2012 at 6:49

1 Answer 1

1

define a global varible e.g

<script>
var title =t'xyz'

$('#abcd').load('page1.html?title='+title,'',function(){})

</script>

you can access title variable in after page1.html load

On the other hand it might not be possible to do this with html if you want to change the content of page1.html, but still can be done using js hacks

if you provide how you want to use title in page1.html , I can help more

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the prompt response. Let me explain my case. I have a single page index.html with a div tag with id 'abcd'. The page has seperate buttons to load seperate pages into this div tag. For example, I click on button A, I load A.html into this div tag. If I click on button B, I load B.html into this div tag. All these multiple pages then load a single common page (page1.html) into the same div tag present in index.html. Now, I am adding parameter 'title' to load function in these multiple pages - A.html, B.html, so that I can track the previous page inside page1.html.
For example. From index.html, I load A.html using $('#abcd').load('A.html,'',function(){}) From A.html, I load page1.html using $('#abcd').load('page1.html?title=A'+title,'',function(){}) Now, I need to access this title in order to track my previous page, i.e., A.html in this case. I hope I am able to clarify my case. Thanks in advance!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.