Limit of POST method in AJAX

Posted on 2007-08-01
Last Modified: 2008-02-01
Hi ppl, I am new here and I have one problem:

I am making one application in with ajax and i want to make POST method  that is longer a lot than usual GET method with ajax because I am integrating one WYSIWYG system that would work in ajax.

And when I try to send some large text data with ajax with POST method it sends me error:

Request-URI Too Large
The requested URL's length exceeds the capacity limit for this server.

And I have asked my hosting provider ( what is the limit for post data sending and they have answered me that is 8Mb and there is the problem.

In short:
I need the code with I can send large text with POST method in AJAX.

Thank you
Question by:galic1987
    LVL 10

    Accepted Solution

    What are you trying to do? Perhaps there is a better method to get the same result.
    LVL 51

    Assisted Solution

    > I need the code with I can send large text with POST method in AJAX.
    either increase your server limits, or you need to split your code into junks, send them to a script which joins them together.

    Author Comment

    the problem is when I send some data with ajax with POST method and the server or browser  handle that data as GET method and sends me that error when I exceed  URL limit for different browser.

    8mb is enough for my project I don't need to increase my server limit.  


    Author Comment

    I have found solution:

          function ajaxprikaz(id, url) {  
          var that=this;                                                  
             var updating = false;  
                                                                                  this.callback = function() {  
             this.update = function(passData, metoda) {                                
                  if (updating==true) { return false; }                        
                  var AJAX = GetXmlHttpObject();  
                  if (AJAX==null) {                                            
                       alert("Vaa broswer nepodr~aje ajax.");                                                            
                       return false                                                
                  } else {
                       AJAX.onreadystatechange = function() {  
                            if (AJAX.readyState!=4){
                                  document.getElementById("loader").innerHTML="<img  src='graphic/ajax-loader.gif' width='16' height='16'>Loading..."
                            if (AJAX.readyState==4 || AJAX.readyState=="complete") {
                               delete AJAX;
                       var timestamp = new Date();
                       var uri;
                       if(metoda == "POST"){
                            uri ='?'+passData+'&timestamp='+(timestamp*1);  
                  , urlCall, true);
                            AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                            AJAX.setRequestHeader("Content-length", uri.lenght);
                            AJAX.setRequestHeader("Connection", "close");
                            return true;    
                       }else if(metoda == "GET"){
                  , uri, true);
                            return true;    
             var LayerID = document.getElementById(id);                    
             var urlCall = url;                                                

    thank you anyway :D

    Author Comment

    one correction :

    if(metoda == "POST"){
                            uri ='?'+passData+'&timestamp='+(timestamp*1);  
                  , urlCall, true);


    if(metoda == "POST"){
                            uri =passData+'&timestamp='+(timestamp*1);  
                  , urlCall, true);

    now works perfect!
    LVL 51

    Assisted Solution

    > the problem is when I send some data with ajax with POST method and the server or browser  handle that data as GET method

    hmm, if you (the browser in particular) sends using POST, then the browser "does not handle it as" GET, nor does the server
    GET and POST are exclusive

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 for Beginning Beginners

    Are you looking for an efficient introduction to HTML5? Have you tried other HTML5 courses and found them too complex? Do you need just the basics of HTML5 to use with Wordpress or other content management system? If you said yes to any of these questions, this course is for you.

    Suggested Solutions

    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now