How to compress GET parameters in Javascript to avoid browser size limitation?

I got into a situation where I need 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 regular request, and I cannot maintain server-side state in order to split the request into several.

Given these limitations, is there a way to compress long text somehow in Javascript so that I can fit within the GET 2000 size limit? I also need to know if I can easily unzip it on the server side?

Since this is a GET request, it can only be sent as text, so binary compression may not be possible?

+6
source share
1 answer

Switch to the original POST data and use JSON or XML to save and send large structures through the request.
If you use jQuery, for example, you have

jQuery.post( url, [data], [callback], [type] ) 

where the data can 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

+2
source

Source: https://habr.com/ru/post/914236/


All Articles