I am trying to retrieve data from a jQuery function.
Here is my function
function getPageHTML() {
$("input").each(function(){
$(this).attr("value", $(this).val());
});
return "<html>" + $("html").html() + "</html>";
}
above I am getting everything inside my 2 <html> and </html> tags with all values inside my inputs.
function send(){
$.ajax({
url:"save-script.php",
type:'POST',
data: getPageHTML()
});
}
Above I am trying to send this data to my save-script.php file. This all works fine but it seems jQuery is interpreting certain character and symbols. The + and the & here.
function getPageHTML() {
$("input").each(function(){
$(this).attr("value", $(this).val());
});
return "<html>" $("html").html() "</html>";
}
my code ends up looking like this after executing the send function.
I have tried using dataType: "html" with no success.
also tried data: encodeURIComponent(getPageHTML()) but this ends up removing all my html.
I am trying to keep all these symbols and not have jQuery interpret these symbols.
getPageHTMLinto a variable & then pass that variable as ajax data.getPageHTML()look like and what's wrong with it?