$ .jsonp的响应类型 [英] response type for $.jsonp
问题描述
我正在使用以下链接调用jsonp https://raw.github.com/ betamax / getImageData / master / jquery.getimagedata.js [ ^ ]
我的jsonp电话
$ .jsonp( {
// async:true,
// crossDomain:true,
类型:' GET',
timeout: 10000 ,
url:' http://sys108/vbr/Handler.ashx?imgURL =' + encodeURIComponent(imageURL)+ ' & type = crossDomainImage',
dataType:' jsonp',
contentType: application / JSON; charset = utf-8,
成功:功能(数据){
console .log(data.ImageData);
},
错误: function (data){
console .log(' error');
}
});
我的回复方法
string imgData = processCrossDomainImage( );
context.Response.ContentType = text / javascript;
string strJson = {\ImageData \\ \\: \ + imgData + \};
// if(context.Request.QueryString [callback]!= null)
// {
/ / strJson = context.Request.QueryString [callback] +(+ strJson +);
// }
context.Response.Write(strJson);
以上代码给出错误未捕获的语法错误意外的令牌:
我的回答看起来像
< pre lang =Javascript> { ImageData: / 9j / 4AAQSkZJRgABAQEAYABgAAD / 2wBDAAICAgICAQICAgIDAgIDAwYEAwMDAwcFBQQGCAcJCAgHCAgJCg0LCQoMCggICw8SPzI5 + pJ / DAr8zxPHfFuPrKdXH1XZp6TaV + mkWl + HkfT08nwGGhpRjrpbl W3XW1 / L / hj8z / AA / qi634L03VAArXMCs6jorY5Faxb1s2k9F5JdvmdGEwFDLqXsqXXVt7vt919A5AA6Y7UUi / 6tfpS1 + yHcFFFFAH / 2Q ==}
不确定但是我我做错了响应设置。请帮忙。
.jsonp({
// async:true,
// crossDomain:true,
类型:' GET',
超时: 10000 ,
url:' http ://sys108/vbr/Handler.ashx?imgURL =' + encodeURIComponent(imageURL)+ ' & ; type = crossDomainImage',
dataType:' jsonp',
contentType: 应用/ JSON; charset = utf-8,
成功:功能(数据){
console .log(data.ImageData);
},
错误: function (data){
console .log(' error');
}
});
我的回复方法
string imgData = processCrossDomainImage( );
context.Response.ContentType = text / javascript;
string strJson = {\ImageData \\ \\: \ + imgData + \};
// if(context.Request.QueryString [callback]!= null)
// {
/ / strJson = context.Request.QueryString [callback] +(+ strJson +);
// }
context.Response.Write(strJson);
以上代码给出错误未捕获的语法错误意外的令牌:
我的回答看起来像
< pre lang =Javascript> { ImageData: / 9j / 4AAQSkZJRgABAQEAYABgAAD / 2wBDAAICAgICAQICAgIDAgIDAwYEAwMDAwcFBQQGCAcJCAgHCAgJCg0LCQoMCggICw8SPzI5 + pJ / DAr8zxPHfFuPrKdXH1XZp6TaV + mkWl + HkfT08nwGGhpRjrpbl W3XW1 / L / hj8z / AA / qi634L03VAArXMCs6jorY5Faxb1s2k9F5JdvmdGEwFDLqXsqXXVt7vt919A5AA6Y7UUi / 6tfpS1 + yHcFFFFAH / 2Q ==}
不确定但是我我对响应设置做错了。请帮忙。
I am using following link to make jsonp call https://raw.github.com/betamax/getImageData/master/jquery.getimagedata.js[^]
My jsonp call
$.jsonp({
//async: true,
//crossDomain: true,
type: 'GET',
timeout: 10000,
url: 'http://sys108/vbr/Handler.ashx?imgURL=' + encodeURIComponent(imageURL) + '&type=crossDomainImage',
dataType: 'jsonp',
contentType: "application/json; charset=utf-8",
success: function (data) {
console.log(data.ImageData);
},
error: function (data) {
console.log('error');
}
});
My response method
string imgData= processCrossDomainImage("");
context.Response.ContentType = "text/javascript";
string strJson = "{ \"ImageData\" : \"" + imgData + "\" }";
//if (context.Request.QueryString["callback"] != null)
//{
// strJson = context.Request.QueryString["callback"] + "(" + strJson + ")";
//}
context.Response.Write(strJson);
Above code gives me error "Uncaught syntax error Unexpected token :
My response looks like
{ "ImageData" : "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAICAgICAQICAgIDAgIDAwYEAwMDAwcFBQQGCAcJCAgHCAgJCg0LCQoMCggICw8SPzI5+pJ/DAr8zxPHfFuPrKdXH1XZp6TaV+mkWl+HkfT08nwGGhpRjrpblW3XW1/L/hj8z/AA/qi634L03VAArXMCs6jorY5Faxb1s2k9F5JdvmdGEwFDLqXsqXXVt7vt919A5AA6Y7UUi/6tfpS1+yHcFFFFAH/2Q==" }
Not sure but i am doing something wrong with response settings.Please help.
.jsonp({ //async: true, //crossDomain: true, type: 'GET', timeout: 10000, url: 'http://sys108/vbr/Handler.ashx?imgURL=' + encodeURIComponent(imageURL) + '&type=crossDomainImage', dataType: 'jsonp', contentType: "application/json; charset=utf-8", success: function (data) { console.log(data.ImageData); }, error: function (data) { console.log('error'); } });
My response method
string imgData= processCrossDomainImage(""); context.Response.ContentType = "text/javascript"; string strJson = "{ \"ImageData\" : \"" + imgData + "\" }"; //if (context.Request.QueryString["callback"] != null) //{ // strJson = context.Request.QueryString["callback"] + "(" + strJson + ")"; //} context.Response.Write(strJson);
Above code gives me error "Uncaught syntax error Unexpected token :
My response looks like
{ "ImageData" : "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAICAgICAQICAgIDAgIDAwYEAwMDAwcFBQQGCAcJCAgHCAgJCg0LCQoMCggICw8SPzI5+pJ/DAr8zxPHfFuPrKdXH1XZp6TaV+mkWl+HkfT08nwGGhpRjrpblW3XW1/L/hj8z/AA/qi634L03VAArXMCs6jorY5Faxb1s2k9F5JdvmdGEwFDLqXsqXXVt7vt919A5AA6Y7UUi/6tfpS1+yHcFFFFAH/2Q==" }
Not sure but i am doing something wrong with response settings.Please help.
这篇关于$ .jsonp的响应类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!