压缩jsonp请求中传递的数据 [英] compress the data passed in jsonp request
本文介绍了压缩jsonp请求中传递的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将大数据(图像数据最多90,000个字符)从一个域传递到我正在使用jsonp的其他域,因为使用jsonp传递的数据大小有限我在数据包中发送数据。有没有办法压缩传递的数据,所以数据包的数量会减少
VAR 跨度> S = <跨度类= 代码串 >跨度> <跨度类= 代码串> ACKCrI / AggggAACCCCAAAIIIIAAAjUQIABQg0oiiwgggAACCCCAAAIIIIAAAggUFSAAUFSQ / RFAAAEEEEAAAQQQQAABBBCogQABgB4IIIAAknnVP9d3yAXnReeNz8x29dtDYC0MnXC3jdFIMa4lW06PgIgaxh0nmHZsQGAmA54O99 + 5 + 38S347EQAITccoe7FIAMDtjNnHi + 3Uhb7H7kvH9 / mymI5tTFnzdGpDIxPaZRAT2ElrxDFOsq + vXtzRJL7OeOxnIu38FfkMoGsRChDChgA7uxNagIECBAgQIAAAQIECBAgcCRgADji8pgAAQIECBAgQIAAAQIECNwp8AOSEl92WlsVrQAAAABJRU5ErkJggg = =跨度>;
$ .ajax({
type: GET,
url: http://sys108/restnew1/RestServiceImpl.svc/GetData,
数据:{
imagedata:s
},
dataType: jsonp ,
contentType: application / json; charset = utf-8 ,
成功:功能(数据){
},
错误: function (jqXHR,textStatus,errorThrown){
if ( window 。 console ) console .log( 错误... + textStatus + + errorThrown) ;
}
});
解决方案
.ajax({
类型: GET,
url: http://sys108/restnew1/RestServiceImpl.svc/GetData,
data:{
imagedata:s
},
dataType: jsonp,
contentType: application / json; charset = utf-8,
成功: function (data){
},
error: function (jqXHR,textStatus,errorThrown){
if ( window 。 console ) console .log( 错误... + textStatus + + errorThrown);
}
});
是的,有一些限制。请阅读我的博客了解更多详情
(413)请求实体太大 [ ^ ]
http://tharakaweb.com/2012/12/11/413-request-entity-too-large/ [ ^ ]
此外,当你是序列化JSON也有一些限制。您可以通过修改web.config文件来避免这种情况,如下所示
< 配置 >
< system.web.extensions >
< 脚本 ing > ;
< webservices>
< jsonserialization maxjsonlength = 102400 />
< / webservices >
< / scripting >
< / system.web.extensions >
< / configuration > 跨度>
I am trying to pass large data(image data up to 90,000 characters) from one domain to other for which i am using jsonp, as there''s limitation to size of data passed using jsonp i am sending the data in packets. Is there any way to compress the data being passed so the number of packets will get reduced
var s="ACKCrI/AggggAACCCCAAAIIIIAAAjUQIABQg0oiiwgggAACCCCAAAIIIIAAAggUFSAAUFSQ/RFAAAEEEEAAAQQQQAABBBCogQABgB4IIIAAknnVP9d3yAXnReeNz8x29dtDYC0MnXC3jdFIMa4lW06PgIgaxh0nmHZsQGAmA54O99+5+38S347EQAITccoe7FIAMDtjNnHi+3Uhb7H7kvH9/mymI5tTFnzdGpDIxPaZRAT2ElrxDFOsq+vXtzRJL7OeOxnIu38FfkMoGsRChDChgA7uxNagIECBAgQIAAAQIECBAgcCRgADji8pgAAQIECBAgQIAAAQIECNwp8AOSEl92WlsVrQAAAABJRU5ErkJggg==";
$.ajax({
type: "GET",
url: "http://sys108/restnew1/RestServiceImpl.svc/GetData",
data: {
imagedata: s
},
dataType: "jsonp",
contentType: "application/json; charset=utf-8",
success: function (data) {
},
error: function (jqXHR, textStatus, errorThrown) {
if (window.console) console.log("Error... " + textStatus + " " + errorThrown);
}
});
解决方案
.ajax({ type: "GET", url: "http://sys108/restnew1/RestServiceImpl.svc/GetData", data: { imagedata: s }, dataType: "jsonp", contentType: "application/json; charset=utf-8", success: function (data) { }, error: function (jqXHR, textStatus, errorThrown) { if (window.console) console.log("Error... " + textStatus + " " + errorThrown); } });
Yes, there are some limitations. please read my blog for more details
(413) Request Entity Too Large[^]
http://tharakaweb.com/2012/12/11/413-request-entity-too-large/[^]
In addition, when you are serializing JSON also have some limitations. you can avoid this by modifying your web.config file as follows
<configuration> <system.web.extensions> <scripting> <webservices> <jsonserialization maxjsonlength="102400" /> </webservices> </scripting> </system.web.extensions> </configuration>
这篇关于压缩jsonp请求中传递的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文