views:

913

answers:

3

EDIT: now the question becomes, how do I tell Sajax to use POST instead of GET? I've tried some examples from google but they are sketchy, and as I said, they didn't work. I know, we're all jQuery nuts around here.

I've used the following code to try and find a limit to the amount of data that can be sent to the server via an ajax call. We use Sajax, obviously. In IE, after somewhere around 1900 characters, the data doesn't get through and we get an error. In Firefox, the limit is somewhere around 6100, but seems to vary a bit on each call. Is this browser-dependent?

Also tried to use POST instead of the default get and telling Sajax to use POST didn't work at all.

Is there a limit to the data stream size sent in AJAX defined anywhere? How about from experience?

<?
    require('sites/includes/Sajax.inc.php');

    function str_length_test($str){
        return strlen($str);
    } 

    sajax_init();
    sajax_export('str_length_test');
    sajax_handle_client_request();

?>
<html>
<head>
    <title>Multiplier</title>
    <script>
    <? sajax_show_javascript(); ?>

    function do_str_length_test_cb(pwd) {
        document.getElementById('str_length').value = pwd;
    }

    function do_str_length_test() {
        sample_field = document.getElementById('sample').value;
        x_str_length_test(sample_field, do_str_length_test_cb);
    }  
    </script>

</head>
<body>

    <textarea id="sample" name="sample" rows=20 cols=60 onblur="do_str_length_test(); return false;"></textarea>
    Size: <input type="text" id="str_length" name="str_length" value="" size=10>

</body>
</html>
A: 

If you're using GET, there's no defined limit. It depends on both the browser making the request and the server receiving it.

POST is usually limited by the server - I think the default for PHP is around 5MB.

Greg
+1  A: 

GET is limited in IE to 2083 chars see http://support.microsoft.com/kb/208427

See here for url length for discussion.

Ryan Watkins
+1  A: 

I see this on the sajax examples:

$sajax_request_type = "GET";
sajax_init();
sajax_export("add_line", "refresh");
sajax_handle_client_request();

I'm guessing you just change the GET to POST.

$sajax_request_type = "POST";
Joel Dare
Thanks for that, I tried that, and now I get no reply instead of an error.
tkotitan