The response is a HTML document (from a request from a link's href)
var data = $(response).find('body').html();
alert(data);
// I get a alert with nothing...
full code:
$.ajax({
url: $(this).attr('href'),
type: 'GET',
success: function(response){
var data = $(response).find('body').html();
alert(data);
}
});
AJAX's most appealing characteristic is its "asynchronous" nature, which means it can communicate with the server, exchange data, and update the page without having to refresh the page. The two major features of AJAX allow you to do the following: Make requests to the server without reloading the page.
An AJAX request is a request made by an AJAX application. Typically, it is an HTTP request made by (browser-resident) Javascript that uses XML to encode the request data and/or response data.
AJAX = Asynchronous JavaScript and XML. AJAX is a technique for creating fast and dynamic web pages. AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.
AJAX = Asynchronous JavaScript And XML. AJAX is not a programming language. AJAX just uses a combination of: A browser built-in XMLHttpRequest object (to request data from a web server) JavaScript and HTML DOM (to display or use the data)
Try it this way:
var $dom = $(document.createElement("html"));
$dom[0].innerHTML = response;
var $body = $dom.find("body");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With