0

I'm trying to send my code to the server (AJAX code editor): Example:

<span class="class">123</span>

On the server side:

$code = $_POST['code']; // Returns me: 123;
$code = $_REQUEST['code']; // Returns me: <span class="class">123</span>;

Why $_POST['code'] returns me stripped result? Thanks!

$('#form').submit(function(e) {
            $.ajax({
                type:       'POST',
                url:            'index.php?option=file&task=templates.save',
                dataType:   'text',
                data:       $("#form").serialize(),
                success: function(data){

                    }
                }
            });

            e.preventDefault();
        });
XTRUST.ORG
  • 3,280
  • 4
  • 34
  • 60
  • You should be testing `if(isset($_POST['code']))`, but that span has nothing to do with AJAX, unless you're just sending useless information that the Client cannot alter to the Server. I would recommend against using `$_REQUEST` anyways, but have no idea why you would get that result. – StackSlave Nov 20 '15 at 02:23
  • http://stackoverflow.com/questions/1924939/request-vs-get-and-post – Lucky Chingi Nov 20 '15 at 02:26
  • this has already been answered http://stackoverflow.com/questions/2496455/why-are-post-variables-getting-escaped-in-php - you have magic_quotes enabled – Marina Nov 20 '15 at 02:32
  • Do you understand difference between strip slashes and strip tags, Marina? – XTRUST.ORG Nov 20 '15 at 02:36

0 Answers0