I’m trying to print the elements of a page using this code:
$('#some_button').click(function(){
var url = window.location.href;
var contents = $.get(url);
alert(contents.responseText);
});
but this returns a blank string, and trying to print contents.status gives me the error:
Uncaught Error: INVALID_STATE_ERR: DOM Exception 11
This code works just fine from the browser console so it would seem this is a load state issue. But because this is in a click listener I don’t know how to solve this.
$.getis asynchronous by default, so use it like this:If you want to use it synchronously, then use
async : falsein the parameters:Note that that will seize up the browser, though.