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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:33:51+00:00 2026-06-11T05:33:51+00:00

Now without having to read boring code let me just summarise what is going

  • 0

Now without having to read boring code let me just summarise what is going on.
An XHR request goes out via jQuery post function when the document loads. The post sends a POST header to a PHP file that calls another php file to process some strings and return it. Finally an echoed json_encode function returns the string to the jQuery post function which the jQuery then manipulates into the DOM.

The result that is returned by JavaScript’s post function is this:

<option value="\&quot;auto2\&quot;">auto2&lt;\/option&gt;</option>

See all those escape characters? Well I tried just echoing the result on the PHP side instead of echoing with json_encode function and it returns:

<option value="auto">auto</option>

Without any other special characters. This is what is desired. My question is, is this okay to use? And why does json_encode add special characters? Is there a way to use json_encode without those other characters being returned?

EDIT

JS

    $(document).ready(function() {
    var PROCESSOR_FILE = "http://address/include/processor.php";

    $.post(PROCESSOR_FILE, {"task": "verticalSelect"}, function(data) {
        $("#verticalSelect").html(data);
    });
});

PHP

$IMEXporterpath = dirname(__FILE__);
$IMEXporterFile = $IMEXporterpath . "/IMEXporter.class.php";

if (isset($_REQUEST["task"]))
    $task   = $_REQUEST["task"];
else
    $task   = "";


    require_once $IMEXporterFile;
    $IMEXp = new IMEXp();

    $result = $IMEXp->returnHtml($task);
    echo json_encode($result);

MORE PHP

public function returnHtml($element) {
        return $this->returnHtml_HTML($element);
    }


    private function returnHtml_HTML($element) {
        if($element == "verticalSelect") {

            $dbTables   = $this->get_Tables();
            $nbTable    = count($dbTables);

            for ($a = 0; $a < $nbTable; $a++) {
                    $ZHTML  .=  '<option value="'.$dbTables[$a].'">'.$dbTables[$a].'</option>';
            }
        }
        return $ZHTML;
    }
  • 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-11T05:33:53+00:00Added an answer on June 11, 2026 at 5:33 am

    On PHP 5.3.13:

    header("Content-Type: text/plain"); // to make sure browser displays raw html
    $str = '<option value="auto">auto</option>';
    
    echo json_encode($str);
    echo "\n";
    echo $str;
    

    Outputs

    "<option value=\"auto\">auto<\/option>"
    <option value="auto">auto</option>
    

    No converted special chars here.

    $.post('test.php').done(function(text){
      return console.log(text);
    });
    

    Prints the same to the console.

    Without AJAX does json_encode($str) display &quot; etc. ?

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

Sidebar

Related Questions

I just developed an iPhone audio streaming application...Now it can play audio files without
I've been working on this for a couple of days now without success. Basically,
I'm pretty fresh to database handling, but now completely without experience. However, I have
So this used to work without a hitch but now I get a Socket
I had an application written without ARC, now I added ARC and I do
I have this regex working but now need to allow numbers without the decimal
I want to check that text is now not present on a webpage without
I got a Project from my Company without Documentation. Now I have to add
I'd like to work with pages without trailing slashes. So now I want my
I can add a normal rightBarButton to my navigation without a problem but now

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.