Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3443622
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:48:49+00:00 2026-05-18T08:48:49+00:00

I am trying to send html via jQuery’s $.ajax() method, and then dump the

  • 0

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:

<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>

the file.php file is:

<?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;
?>

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:48:50+00:00Added an answer on May 18, 2026 at 8:48 am

    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());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send a variable with jQuery's getJSON function but it doesn't
I am trying to send an XML file from a textfield in my html,
Trying to send array + vars with Ajax, Sending just the array worked fine...but
Im trying to send a custom HTML object from my ASP 2.0 website to
I've been trying to send an email from my magento module but for some
Trying to send an array from: <select name='galaddvenn[]' class='sel_add vl hidden' multiple='multiple'> <option value='53'>name1</option>
I am trying to send my logged in users details along with this request,
I am trying to send the value of a radio button to a javascript
I'm trying to hunt down why a POST request from a C# script isn't
I have an issue that appears in all browsers. I am working with ASP.NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.