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 8567467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:53:27+00:00 2026-06-11T17:53:27+00:00

Im trying to encode some html within json from PHP. The function requests data

  • 0

Im trying to encode some html within json from PHP. The function requests data from a PHP file, and then will append it into the html page. The function works fine until I have < or > within the string I am trying to pass. This is my PHP code:

$append = "<b>Edit</b>";
for($i=0;$i<count($atarray);$i++)
{
    $append .= $atarray[0]['atname'];
}
$json = json_encode(array('ok' => '0', 'apso' => $append));
echo $json;

This works fine, if instead of "<b>edit</b>" I use "Edit", is there a way to get it to work including the HTML tags?

The error that comes up in console is Uncaught SyntaxError: Unexpected token < jquery-1.7.js:2 whenever I run the function.

JavaScript

I’m using the jQuery form plugin -> http://archive.plugins.jquery.com/project/form
It’s sending the variables as POST data

but this is my function

$(function(){
$("#change").submit(function(e){
    e.preventDefault();
    $(this).ajaxSubmit({
        beforeSubmit:function(before){
            $('#loadingsignup').show();
            $("#resultsignup").empty().hide();
        },
        success:function(retour){
            $('#loadingsignup').hide();
            res=jQuery.parseJSON(retour);
            if(res.ok==1){
                $('#resultsignup').append('<p class="good"><?php echo $lang['107']; ?></p>');
                if(res.img!==undefined){
                    $('#eaim').attr('src','/images/artistsprofilepic/'+res.img);
                }
            }else if(res.apso!==undefined){
                var ap=res.apso;
                $('#apso').append(ap);
            }else{
                $('#resultsignup').append('<p class="pasgood">'+res.err+'</p>');
            }
            $("#resultsignup").hide().fadeIn(500);
            setTimeout("$('#resultsignup').fadeOut();",5000);
        }
    });
});
});
  • 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-11T17:53:28+00:00Added an answer on June 11, 2026 at 5:53 pm

    Try getting rid of the call to jQuery.parseJSON, and use the option dataType: 'json'. .ajaxSubmit uses jQuery.ajax, which tries to figure out the format of the response, and it may have determined that it was JSON, so it was already parsed. Parsing it again results in this error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to retrieve some data from JSON object which holds location information such
I've written a CMS which uses the PHP function json_encode to send some data
I am trying to use the data I have received from a php script,
I'm trying to parse json data from google directions but can't seem to access
I'm trying to html encode a string that will be used as a tooltip
I am trying to write some data pulled from some source code (using httplib2
I've been going bananas trying to get some data from Javascript on one page
I am using ajax to pull some data from a PHP script I created.
I'm trying to load some data via. jquery $get_desc = SELECT tekst_id,overskrift FROM rr_tekster
I'm trying to use jQuery.post() function to retrieve some data. But i get no

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.