Javascript Variable Limitation?
5 Replies
Here is the code I'm using with a Wordpress slider:
var currentActiveSlide = '';
function loadContent( e) {
currentActiveSlide = e;
jQuery.post(template_url + '/ajax.php', { 'action': 'slideContent', 'rel': e.attr('rel') }, function(data) {
e.html(data.substring(0, data.length - 1));
});
}
Your Linode doesn't have any real limit to what it can send. I know that cookies have a size limit (I think it's 4k but can be set up to 8k in the Apache config IIRC).
You should probably be asking a jquery (or general javascript) forum about this limit. I know some browsers (which may be adhering to industry standards) have a 4k limit on what DOM objects can hold.
If you really need to return more than 4k of data from an ajax request maybe you can split it up into multiple segments that are assigned to array elements upon receiving your responseText.
Have your server code split the response into segments that are a maximum length of 4k and use URL friendly separator characters between the segments (eg, '%|%').
Split your responseText into an array (eg, var results = xmlHttp.responseText.split('%|%'); ) and pass the results array to your callback routine.
Your callback routine can walk the array and append the segments to the target html element (if that's what you're doing).
If your results are encoded in base64 then the above process won't work as described. You'd have to split your results at the server into segments that are less than 3k each and have them base64 encoded before assembling your large response (separated by your characters of choice). You'd then have to have each array element decoded before using it.
Keep in mind that segmenting your server response into logical segments is the best approach (even if they are well below the 4k limit).
MSJ