1

I'm trying to use load to reload a portion of the current page (long story why) but am having an issue with the variable syntax.

Here is the snippet of code:

var pathname = window.location.pathname; $('#menu').load("/cms.php #menu"); 

I woudl like to replace /cms.php with the variable, but am having issues with the corrent syntax.

Any help/advice would be much appricated.

A.

4 Answers 4

7

Based on your example, to add in the pathname var just do the following, although why have you specified "#menu' at the end of the Load string.

var pathname = window.location.pathname; $('#menu').load(pathname +" #menu"); 
Sign up to request clarification or add additional context in comments.

Comments

3

May be you can try :

var pathname = window.location.pathname; $('#menu').load(pathname+' #menu'); 

Comments

2
var pathname = window.location.pathname; $('#menu').load(pathname+" #menu"); 

should do the job

Comments

-2

Just came across my own question (posted months ago). Easiest way is:

$('a').click(function() { $('#copy').load(this+"#cms"); return false; }); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.