I have gotten myself into a situation where I am required to make a JSONP Ajax GET request (cross domain) and I need to send a document > 2000 characters in length as a parameter.
For various reasons, I cannot change it from JSONP to a normal request and I cannot maintain state on server side to split the request into several.
Given these limitations, is there a way to compress the long text somehow in Javascript so I can fit it inside the 2000 GET limit size? I'd also need to know if I can easily decompress it on server side?
Because it is a GET request it can only be sent as a text so binary compression may not be possible?
Switch to POST raw data and use JSON or XML for saving and sending big structures via a request.
If you use JQuery for example you have
jQuery.post( url, [data], [callback], [type] )
where data could be xmlDoc, jsonObj, html, text, etc...
instead of data you could have something like:
$.post("path/to/my/file.php", { func: "yourFunctionName" },
function(data_returned_from_backend_json){
//use data_returned_from_backend_json.properties
}
, "json");
function yourFunctionName()
{
//save all GET params into a json structure
}
source: http://docs.jquery.com/Post
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With