Я пытаюсь отправить html с помощью метода jQuery $ .ajax (), а затем вывести html в новый файл .html, но по какой-то причине его содержимое обрезается.
Я настроил контрольный пример:
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script >
$(document).ready(function(){
var contents = $('html').html();
var filename = "test/000.html";
$.ajax({
type: "POST",
url: "/file.php",
data: "content="+contents+"&fn="+filename,
dataType: "html",
success: function(msg, ts, xh){
console.log(msg);
console.log(ts);
console.log(xh);
alert("success");
},
processData: false,
error: function(X, textStatus, error){
alert("Error saving... please try again now.")
}
});
});
</script>
</head>
<body>
<div id="rteContainer" class="dev">
<div id="textEditor">
<form>
<textarea name="balh" id="balh" rows="25" cols="103"></textarea>
<input type="button" id="updateContent" value="Update Changes">
<input type="button" id="closeEditor" value="Close Without Saving">
</form>
</div>
</div>
</body>
</html>
Файл file.php:
<?php
header("Content-type:text/html;charset:UTF-8");
$content = "<html>".stripslashes(urldecode($_POST["content"]))."</html>";
$dump_file = $_POST["fn"];
$fp = fopen($dump_file, 'w');
fclose($fp);
echo $content;
?>
Почему его отрезали? Я предполагаю, что это проблема кодирования, но я не могу понять это.