Max URL Length

Apr 25 2012 8:00 AM APR 25 2012 8:00 AM
Using GET has a maximum character length.Apache | JQuery | HTML | Javascript

Web Browsers have maximum character lengths that once reached will break a GET request.

Internet Explorer has a maximum character limit of 2,083.

FireFox, Safari and Opera can go over 80,000 characters. 

In some cases I have discovered FireFox has a limit similar to IE. 

Microsofts explanation of their limit:

Microsoft Internet Explorer has a maximum uniform resource locator (URL) length of 2,083 characters. Internet Explorer also has a maximum path length of 2,048 characters. This limit applies to both POST request and GET request URLs. If you are using the GET method, you are limited to a maximum of 2,048 characters, minus the number of characters in the actual path. However, the POST method is not limited by the size of the URL for submitting name/value pairs. These pairs are transferred in the header and not in the URL. RFC 2616, "Hypertext Transfer Protocol -- HTTP/1.1," does not specify any requirement for URL length.

Recently in this large project I am working on that is being slowly released to our client we have discovered numerous issues. Mostly poorly developed sections of code because of the speed that is being required of us developers.

One section of code I discovered was doing a Ajax call using JQuery.

.load( url [, data] [, complete(responseText, textStatus, XMLHttpRequest)] )

http://api.jquery.com/load/

This is a shorthand version of an ajax call. The response we needed was an HTML response that evaluates the javascript and returns the completion. This call obviously has the 2083 limit and was breaking our response needed.

I found myself attempting the $.post() short hand method but found myself going back to an ajax call with a different dataType return. ($.post()) does have the ability to change the return type...

$.ajax({
		          type: "POST",
		          url:  '/project/ajax.php',
		          data: paramsLongerThan2083,
		          dataType: "html",
		          success: function (data) {
		              	$('body').html(data);
		          }
});

This handles as expected it does what I needed just as the load did, but using POST. Yes I could have used the $.post syntax but I like the visibility of a function and not the shorthandlings.