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

  • Home
  • SEARCH
  • 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 8428485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:04:15+00:00 2026-06-10T05:04:15+00:00

I have an iframe which is editable to be used as post input for

  • 0

I have an iframe which is editable to be used as post input for a blog.
I’m using jQuery to retrieve the html from the body of the iframe:

function sharePost (feedNumber)
{
  var postBox = $("#ifrNewPost" + feedNumber).contents(); // Gets iframe content
  var postContent = $('body', postBox).html(); // Gets iframe body

  var params = { post: encodeURI(postContent) };

  // Send to server
  $.ajax({

    type:'POST', 
    url: 'script/post.php', 
    data: params, 

    success: function(response) {
      $(document).append(response);
    }

  });
}

Nearly works perfectly, my problem is that when I paste something into the iframe, there seems to be a newline added to the start of what I paste, then when submitted, the script is failing with:
“Uncaught SyntaxError: Unexpected token ILLEGAL”

I have tried encodeURI and encodeURIComponent to no avail. When I view the code of the page after pasting there are no apparent changes to what I paste, it just appears to have a new line added before it. Any solutions on how to send the HTML safely through to my php script?

  • 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-06-10T05:04:17+00:00Added an answer on June 10, 2026 at 5:04 am

    The problem was with what the php code was returning after all!
    Simply running a regex to change any newlines to br’s did the job!

    $post = preg_replace("/(\r\n|\n|\r)/", "<br />", $post);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

on my page I have an iframe which is loading an html form from
I have an embedded iframe form which takes a file from a type=file form
I have an iframe which I'm trying to center using CSS, but is there
I have a an iframe which inside there is a video link from somwhere.
I have a form inside an iframe which is inside a jQuery UI dialog
I have an iframe from which I am trying to send a XMLHttpRequest. Here
I have a form which contains: <button class="submit">Submit</button> and jQuery code: $(".submit").click(function(e){ var evt
So I have an Iframe in which I hawe opened a html document with
Below is the Html button and javascript function I have which closes a modal
I have an iframe which lets say that it contains the following text: <h1>

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.