I
I
iamsaint2012-02-28 10:20:08
JavaScript
iamsaint, 2012-02-28 10:20:08

jQuery $.getJSON?

Good afternoon.
I pass the value of the textarea field to the php script via $.getJSON

$.getJSON("./ajax/data.php",
  {
    comment  : $("#comment").val()
  },
  function(data) {
    ...
  });


If $("#comment").val() <= 512 is long, everything is fine, but with >512 in the php script I get an empty variable value.
Can you please tell me how to transfer a text longer than 512 characters in this case?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Skpd, 2012-02-28
@Skpd

The problem appears due to the limitation of the query string GET request to 512 bytes. It's better to use POST, for example:

$.ajax({
    url: './ajax/data.php',
    type: 'POST',
    data: {comment: $("#comment").val()},
    dataType: 'json',
    success: function(data) {
        //...
    }
})

A
Anton, 2012-02-28
@sHinE

 $.post("./ajax/data.php",
    {
        comment  : $("#comment").val()
    },
    function(data) {
        ...
    },"json");

maybe so?

K
kns, 2012-02-28
@kns

Perhaps some suhosin cuts off. It happens to him, see the config.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question