Limit of POST method in AJAX

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 (servage.net) 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
Ivo
galic1987Asked:
Who is Participating?
 
wildzeroCommented:
What are you trying to do? Perhaps there is a better method to get the same result.
0
 
ahoffmannCommented:
> 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.
0
 
galic1987Author Commented:
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.  

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
galic1987Author Commented:
I have found solution:

      function ajaxprikaz(id, url) {  
      var that=this;                                                  
         var updating = false;  
                                                                              this.callback = function() {  
                                                                           //checkmeni();      
                                                                            }
         this.update = function(passData, metoda) {                                
              if (updating==true) { return false; }                        
              updating=true;                                                
              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") {
                           LayerID.innerHTML=AJAX.responseText;                  
                           delete AJAX;
                           document.getElementById("loader").innerHTML="";
                           updating=false;                                      
                           that.callback();
                                    
                        }                                                        
                   }                                                          
                   var timestamp = new Date();
                   var uri;
                  
                   if(metoda == "POST"){
                        uri ='?'+passData+'&timestamp='+(timestamp*1);  
                        AJAX.open(metoda, urlCall, true);
                        AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                        AJAX.setRequestHeader("Content-length", uri.lenght);
                        AJAX.setRequestHeader("Connection", "close");
                        AJAX.send(uri);                                            
                        return true;    
                   }else if(metoda == "GET"){
                        uri=urlCall+'?'+passData+'&timestamp='+(timestamp*1);  
                        AJAX.open(metoda, uri, true);
                        AJAX.send(null);                                            
                        return true;    
                   }
              }                                                                      
         }
         var LayerID = document.getElementById(id);                    
         var urlCall = url;                                                
}

thank you anyway :D
0
 
galic1987Author Commented:
one correction :
FROM:

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

TO:

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

now works perfect!
0
 
ahoffmannCommented:
> 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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.