消除使用JSONP发送数据的限制 [英] To remove limitation on data send using JSONP

查看:89
本文介绍了消除使用JSONP发送数据的限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以消除使用JSONP发送数据的限制吗?下面是我的代码.我想做的是一次传递3000个字符(准确地将图像转换为base64数据)传递给service(serviceCall.ashx).由于我的数据很大,最多30,000-40,000个字符,因此我将其分成数据包(每个3000个),然后发送.有什么办法我可以一次性发送这些完整的数据.切换到JSONP的原因是为了避免在IE上弹出此页面正在访问非...的信息".我知道JSONP使用GET方法时,显然会有数据限制,但是有什么方法可以解决此问题.

Can we remove the limitation on data send using JSONP. Below is my code. What i am trying to do is to pass 3000 characters(actuallly a image which is converted to base64 data) at a time to service(serviceCall.ashx). As my data is large up to 30,000-40,000 characters i am dividing it in packets(3000 each ) and then sending it. Is there any way i can send this complete data in one go. Reason for switching to JSONP is to avoid the pop up on IE which says ''This page is accessing info that is not.....''. I know as JSONP uses GET method there would obviously a data limitation but is there any way to work around this problem.

$.ajax({
        type: "GET",
        url:'http://sys108/restnew1/serviceCall.ashx',
        dataType: "jsonp",
        contentType: "application/json; charset=utf-8",
        async: false,
        data: { 
         datachunk: imgdatachunk,
         packetlen: imgdatachunk.length, 
         imagekey: imageid },

         success: function (data) {
  },
         error: function (jqXHR, textStatus, errorThrown) {
                 if (window.console) console.log("Error... " + textStatus + "        " + errorThrown);
                                            }
                                        });

推荐答案

.ajax({ 类型:" , 网址:' http://sys108/restnew1/serviceCall.ashx', dataType:" , contentType:" , 异步:错误, 数据: { datachunk:imgdatachunk, packetlen:imgdatachunk.length, imagekey:imageid}, 成功:功能(数据){ }, 错误:函数(jqXHR,textStatus,errorThrown){ 如果(窗口.控制台)控制台 .log(" + textStatus + " + errorThrown); } });
.ajax({ type: "GET", url:'http://sys108/restnew1/serviceCall.ashx', dataType: "jsonp", contentType: "application/json; charset=utf-8", async: false, data: { datachunk: imgdatachunk, packetlen: imgdatachunk.length, imagekey: imageid }, success: function (data) { }, error: function (jqXHR, textStatus, errorThrown) { if (window.console) console.log("Error... " + textStatus + " " + errorThrown); } });


阅读以下内容: http: //stackstackflow.com/questions/9121158/json-parameter-size-limit [
Read the following : http://stackoverflow.com/questions/9121158/json-parameter-size-limit[^]


这篇关于消除使用JSONP发送数据的限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆