2
In this ajax the post sends more than 1000 characters:
$.ajax({
url: 'inserir.php',
type: 'POST',
data: { inseason: document.getElementById('comment').value },
success: function(result) {
alert('the request was successfully sent to the server');
}
});
But in this other one it has a maximum of 1000 characters and I can’t figure out why.
var http = new XMLHttpRequest();
var parametros = "inseason=" + document.getElementById('comment').value;
http.open("POST", "inserir.php", true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() {
if(http.readyState == 4 && http.status == 200)
{
//console.log(http.responseText);
$('#logs').text(http.responseText);
}
}
http.send(parametros);
How did you find that the first sends more than 1000 characters and the second does not?
– Woss
I have a textarea to put the result of the script , and in the second the post only sends 1000 characters
– manitoramos
And what is the code of
inserir.php
?– Woss
Colloquium
console.log(http.responseText.length);
after$('#logs').text(http.responseText);
and see what it shows on the console– Sam
now I was testing how many Cars passed with console.log(http.responseText.length); and found that when I pass a & in the code it confuses as more parameters and then only gives me the characters to the &
– manitoramos
Puts
escape()
, thus:escape(document.getElementById('comment').value)
– Sam
This will escape special characters such as &.
– Sam
That’s right, thank you
– manitoramos
Since I gave a hint and you found the main error, it would be nice if you posted an answer telling how the problem was solved and then mark as right, to give the question as finalized. Abs!
– Sam
I’ll do that but I can only accept my answer after two days.
– manitoramos