-1

I am using following code to send form data from php

<script type="text/javascript">
        $(document).ready(function() {  
            $('#preloader').hide();         
            $('#preloader')
                    .ajaxStart(function(){
                            $(this).show();
                    }).ajaxStop(function(){
                            $(this).hide();
                    });                                                                                                     
            $('#form form').submit(function(){
                    $('#result').empty();
                    $.get('something.php', $(this).serialize(), function(data){                                                  
                            $('#result').html(data);
                    });                     
                    return false;
            });
        });
</script>

It's working fine but not working when form has large data, please suggest me how to send it.

Bhumi Shah
  • 9,323
  • 7
  • 63
  • 104
Ashok sri
  • 33
  • 1
  • 9

3 Answers3

0

You have to change the values of -

  1. Post Max Size
  2. For just your information adding To Upload File.

You can do it with .htaccess file or in php.ini

  1. .htaccess

    php_value upload_max_filesize 20M
    php_value post_max_size 64M
    
  2. php.ini.

    ; Maximum allowed size for uploaded files.
    upload_max_filesize = 64M
    
    ; Maximum post allowed size 
    post_max_size = 64M
    

Note: You have to restart your server after changing the value in php.ini.

Rajesh Ujade
  • 2,715
  • 19
  • 39
0

i've changed the $get into $post,so now it's working fine

$.get('something.php', $(this).serialize(),.. to $.post('something.php', $(this).serialize(),..

Ashok sri
  • 33
  • 1
  • 9
-1

It seems the problem is in the $.get() function you use - the GET method cannot handle data larger than 255 chars. Try to use $.post() function instead.

Chetan Gawai
  • 2,361
  • 1
  • 25
  • 36
Yuri Seng
  • 1
  • 1
  • 1
    URL's are limited to 2048 chars at least on IE (that is in this circumstance the lowest common denominator). Saying it is limited to 255 chars is wrong. The sum of the length of properties, values, the URL base and characters such as `&`, `?` and `=` should not exceed 2048 chars in length to be cross browser compatible. – David Barker Oct 06 '14 at 06:45
  • It actually depends on server configurations but it safer to assume 255 chars for compatibility. [here](http://stackoverflow.com/questions/2659952/maximum-length-of-http-get-request) is good told about. – Yuri Seng Oct 06 '14 at 07:16
  • Yes the server does need to accept a specific size of URL. However, Apache, IIS and nginx defaults to allow for high URL sizes upwards of 8k. It is very safe to assume in modern web environments that the browser sets the hard cap. – David Barker Oct 06 '14 at 07:32
  • You never know how old user's browser is and the topicstarter didn't said which one is in use and how big the bunch of data have to be sent is. But according to user2049768's answer the advice works. However I apologize for possible misleading. – Yuri Seng Oct 06 '14 at 07:41
  • Well the cap on ie dates back to ie4 http://support.microsoft.com/kb/208427 so again very safe to assume no one is going to be using a browser that old ;-) down vote removed for your last comment. – David Barker Oct 06 '14 at 07:48