I am sending my entire page html back to server using jquery ajax post
My code is like this
$(document).ready(function () {
var pcontent = document.body.innerHTML;
var url = new URI().addQuery("pcontent", pcontent);
$.ajax({
url: url, type: "POST"
, success: function (data) {
alert(data.html());
},
complete: function () {
alert(1);
},
error: function (jqXHR, error, errorThrown) {
if (jqXHR.status) {
alert(jqXHR.responseText);
} else {
alert("Something went wrong");
}
}
});
return false;
});
but the code makes an error like this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Request URL Too Long</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Request URL Too Long</h2>
<hr><p>HTTP Error 414. The request URL is too long.</p>
</BODY></HTML>
as far as i understood i cant send entire page html through an ajax post.Is it true? or is there any thing else that makes this error for me?
The are limitation on number of characters in the URL. You can have max 2000 characters in your URL.
Don’t send your html in URL, instead use “data” parameter of jquery ajax.
Something like