views:

262

answers:

5

Hi,

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.

+2  A: 

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");
Pino
+1  A: 

May be you can try :

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

should do the job

harpax
A: 

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

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

This doesn't work for me. I don't get it.

Ken