1

When i post data with ajax json in one line

<p>test</p>

everything is ok, but when i post data in two-line :

<p>test</p>
<p>test</p> 

i got error 403

Using FireBug i see this information: for one-line : sastojci=%3Cp%3Efasdfasd%3C%2Fp%3E

for two-line: sastojci=%3Cp%3Efasdfasd%3C%2Fp%3E%0A%3Cp%3Efasdfasd%3C%2Fp%3E

this is code for json: // #sastojci is textarea

$('#update').submit(function(){

$sastojci = $('#sastojci').val();

$.ajax({
    type: "POST",
    dataType: "json",
    data: { sastojci : $sastojci},

    url: 'updatedata.php',
    success: function(data) {

        alert(data.poruka);

    },
    error: function (data, textStatus, jqXHR) { 
        alert(data.status); 


    } 

});

return false;
}); 

This is update for my question:

If i use input insed of textarea, the error is 403 again

If i post:

<p>test</p>p>test</p>

everuthing is ok.

If i post:

   <p>test</p><p>test</p>

error is 403 forbiden : You don't have permission to access updatedata.php on this server.

The only diference is "<" ??? I have no idea what is hepening here!!!

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
  • The difference is in `0A%` presents in multiline. Why your server generates `forbidden` (403) on error? There is some server side error. Post your server code processing input. – s.webbandit Sep 17 '12 at 12:39
  • The encoded line feed as mentioned above is the problem. See here http://stackoverflow.com/questions/395379/problem-when-retrieving-text-in-json-format-containing-line-breaks-with-jquery – Timm Sep 17 '12 at 12:58
  • In this case, the problem is not with new line. If I send one one-line, and in second line is only text, without paragraf, everything is ok. And this code works perfecty on another server! – user1677607 Sep 17 '12 at 13:10

0 Answers0