jQuery: Load body of page into variable

Posted by Nathan G. on Stack Overflow See other posts from Stack Overflow or by Nathan G.
Published on 2011-03-13T21:35:54Z Indexed on 2011/03/14 0:09 UTC
Read the original article Hit count: 143

Filed under:
|
|
|

I'm using jQuery to load the result of a PHP script into a variable. The script is passed something that the user typed with a GET request. I want to take just what the script spit out into its <body> tag. Here's what I've tried:

JS:

function loader() {
    var typed = $('#i').val(); //get what user typed in
    $.get("script.php", {i: typed}, function(loaded) {dataloaded = loaded;});
    alert($(dataloaded).find('body'))
}

But it just displays [Objec object]. How can I get a useful value that is just the contents of the body of a loaded page?

I know the PHP works, I just need the JS.
The script echos something like 1!!2 (two numbers separated by two exclamation points).

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript