Sending current page html back to server through ajax

Zvdduzvpdrrok

New Member
In my application i am sending back the html of my webpage to server through jquery ajax (as i need to store a copy of this page in server).Code is like this\[code\]$(document).ready(function () { var pcontent = document.body.innerHTML; var url = new URI().addQuery("pcontent", pcontent); $.ajax({ url: url, type: "GET", 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;});\[/code\]But this throws an error:\[code\]<!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>\[/code\]Is there any way to achieve this?Edit:from the inputs i got from here i had changed my code like this (changing get to post)\[code\] $(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;});\[/code\]but still the same error exissts
 
Back
Top