I have been looking around for answer to this question for a bit, but I cant seem to find anything that helps. I would like to say first that I am relatively new to javascript/jQuery/Web Development in general (I come from more of a software background).
I am trying to get text from another page to display on my home page, or even use the text as a variable. Here is what I have so far, but I am not getting the results I am looking for.
Page 1 (the home page, just the jQuery, trying to output the return in console first)
$(function(){
$.get('Page2.html', function(result){
var obj = $(result).find('body');
var PageText = $(result).find('testJQ').text();
console.log(PageText);
});
});
Page2 (The page with the info I would like to grab)
<body>
<p id="testJQ">This is the text I want</p>
</body>
I get an undefined from the console, but I am unsure why. Like I said, I am fairly new with jQuery, and dont know exacly what is going on. These sites are in the same domain, so there shouldnt be any security issues grabbing information from one another.