Content sent through jQuery ajax is getting cut off

I am trying to send html via jQuery's $.ajax() method, and then dump the html into a new .html file, but the content is getting cut off for some reason.

I have set up a test case:


<script type="text/javascript" src=""></script> 
<script >
      var contents = $('html').html();
      var filename = "test/000.html";
         type: "POST",
         url: "/file.php",
         data: "content="+contents+"&fn="+filename, 
         dataType: "html",
         success: function(msg, ts, xh){
         processData: false,
         error: function(X, textStatus, error){
             alert("Error saving... please try again now.")



<div id="rteContainer" class="dev">
  <div id="textEditor">
    <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">


the file.php file is:

$content = "<html>".stripslashes(urldecode($_POST["content"]))."</html>";
$dump_file = $_POST["fn"];
$fp = fopen($dump_file, 'w');
echo $content;

Why is is getting cut off? I'm guessing it's come encoding problem, but I can't figure this out.


The html string, contents, has to be url-encoded before you POST it. Javascript provides the escape() function, just for this purpose.

Pass $('html').html() to escape() and assign it to contents, like so:

var contents = escape($('html').html());

Need Your Help

How to add fasync function to the kernel module code?

kernel driver

Kit: Beagle Bone Black, OS: Angstrom, kernel: