I have a website that runs queries on the server, which is running Mongrel. The query syntax can get quite involved, and I just ran a query (HTTP request) that yielded this error.
All workarounds welcome.
EDIT: Here’s the full ajax command:
$.ajax({
type: "POST",
url: '/parsequery/' + jsonQuery,
beforeSend: function(x) { // this is needed because otherwise jquery doesn't see the returned data as json
if(x && x.overrideMimeType) {
x.overrideMimeType("text/html");
}
},
datatype: 'json',
success: function(data, textStatus) {
if (parsedOK(data)) {
executeQuery(jsonQuery);
}
else {
handleFailedParse(data);
}
},
error: function(jaXHR, textStatus, errorThrown) {
alert("error sending request: " + textStatus)
}
});
You should use HTTP POST for that. Many server and browser implementations have tight limits on the query length, something around 1 kByte or 2 kBytes.
So instead of
you should do
And in case you do not do the requests via forms, you could use jQuery for instance:
See here for examples: http://api.jquery.com/jQuery.post/
Of course the server side needs to handle POST requests. But changing from GET to POST on the server side is should be from a programming point of view trivial.