Nate Nate - 6 months ago 14
Ajax Question

Sending the body of a page to another server?

Is it possible to send the body of a page (i.e. all of the HTML code/DOM) from a page on one server to another and then receive a response? The method used doesn't really matter, but I do have access to jQuery functions if that helps.

Answer

You could do this by sending...

$("html").html();

...in an ajax call:

var data = $("html").html();
$.ajax({
    url: "/echo/json/",
    data: data,
    type: "POST"
}).done(function(res) {
    console.log(res);
});

Working jsFiddle: http://jsfiddle.net/brandonscript/p5zEW/

(See console for body output).