How Can I Dynamically Add A Url Into Javascript, To Get A Second Page's Div To Display On The First Page?
Ok, so this what I have that works, for the starting code: $(document).ready(function(){ $('.currentpagediv').load('http://theurl.com/page2/somethingsomewhere.html .secondpagediv
Solution 1:
You're just missing the string concatenation operation, +
.
$('.currentpagediv').load(changeURL() + ' .secondpagedivclass');
Don't forget the space before .secondpagedivclass
.
The changeURL
function needs to return the result:
function changeURL() {
var theURL = location.pathname;
var newURL = theURL.replace("/page1/", "/page2/");
return newURL;
}
You don't need to use .toString()
, since the pathname is a string.
Post a Comment for "How Can I Dynamically Add A Url Into Javascript, To Get A Second Page's Div To Display On The First Page?"