ajax 跨域 ,后台只返回json数据,有什么解决办法吗

ajax 跨域 ,后台只返回json数据,后台不更改 返回数据格式,有什么办法吗

跨域用的就是jsonp但使用jsonp不能直接接收json数据会报错
我问的是使用jsonp有什么办法可以让他接收json数据

服务器端做代理,或者用yql转为jsonp数据
JSONP跨域访问在线代理API

ajax跨域的话可以用jsonp,你可以研究下

使用jsonp就可以解决跨域问题

没太明白什么意思,用ajax是返回json格式的数据呀,你的问题是什么?

两种解决方案 一种使用jsonp 请求 但是只能是get请求 另外一种设置请求头
resp.setHeader("Access-Control-Allow-Origin", "*");
resp.setHeader("Access-Control-Allow-Methods", "POST, PUT, GET, OPTIONS, DELETE"); //哪种请求可以访问
resp.setHeader("Access-Control-Max-Age", "3600"); //设置过期时间
resp.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, client_id, uuid, Authorization");
resp.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // 支持HTTP 1.1.

HttpServletResponse httpServletResponse = (HttpServletResponse) response;

      httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");

      httpServletResponse.setHeader("Access-Control-Allow-Headers", "accept,content-type");

      httpServletResponse.setHeader("Access-Control-Allow-Methods", "OPTIONS,GET,POST,DELETE,PUT");

      chain.doFilter(request, httpServletResponse);

switch(dt)
{
case "initinlocal":
dt = "json";
success( that.options.initData, null, null );
this.options.initData = false;
break;
case "json":
case "jsonp":
if ( this.xhr ){
this.xhr.abort();
}
this.xhr = $.ajax(this._ajaxSettings( ));
this.xhr
.success(function(content, st, xhr) {
success( content, st, xhr );
}).error(function(xhr,st,err) {

that._trigger ("onLoadError", null, [{xhr:xhr,st:st,err:err}]);
if (npage === 1) { that._endReq(); }
xhr=null;
that.refresh();
}).complete(function( jqXHR, status ) {
if ( jqXHR === that.xhr ) {
that.xhr = null;
}
});
break;
case "local":
case "clientside":
that._beginReq();
that.options.datatype = "local";
var req = that._addLocalData();
this._addJSONData(req,grid.rowsView,rcnt,npage>1,adjust);
if(!that.options.b_sortdata){
that.refresh();
if(lc) { lc.call(that,req); }
that._trigger("AfterLoad", null,[req]);
if (pvis) { grid.populateVisible(); }
}
that._endReq();
if (that.options.frozenColumns) {
that._setFrozenHeight();
}
break;
}

        希望对你有帮助!!!!

ajax跨域服务端必须做修改,或者header里加Access-Control-Allow-Origin或者使用jsonp。看了下你的说法,不想更改原后台返回数据的格式还想使用jsonp,基本不可能,你应该还没理解jsonp的原理。