我正在收到一个' parseResponse'在向地理服务器发出请求时,它不是一个函数。我尝试了几件事来解决这个问题,但结果仍然存在:' parseResponse不是函数'
我尝试在fetch中设置同步选项, 我尝试使用cache:true, 我确实覆盖了同步
我确实研究过这些可能的解决方案: how to set backbone fetch callback method
Caching jsonp callback parameter when doing a backbone fetch
这是代码:
var APP = APP || {};
APP.WaterDepthStatusModel = Backbone.Model.extend({
url: '',
initialize: function (url) {
this.url = url;
},
calcUrl: function (xy, mapInfo, RD, mapUrl, emptyInfo) {
var mapWidth = mapInfo._size.x;
var mapHeight = mapInfo._size.y;
var boundsNE = RD.projection.project(mapInfo.getBounds().getNorthEast());
var boundsSW = RD.projection.project(mapInfo.getBounds().getSouthWest());
var BBOX = boundsSW.x + ',' + boundsSW.y + ',' + boundsNE.x + ',' + boundsNE.y;
var zoom = mapInfo.getZoom();
var buildUrl = mapUrl;
buildUrl += '?REQUEST=GetFeatureInfo';
buildUrl += '&EXCEPTIONS=application/vnd.ogc.se_xml';
buildUrl += '&INFO_FORMAT=text/javascript';
buildUrl += '&format=image/png';
buildUrl += '&QUERY_LAYERS=' + APP.servers.waterDepthStatus;
buildUrl += '&Layers=' + APP.servers.waterDepthStatus;
buildUrl += '&BBOX=' + BBOX;
buildUrl += '&WIDTH=' + mapWidth;
buildUrl += '&HEIGHT=' + mapHeight;
buildUrl += '&x=' + xy.x;
buildUrl += '&y=' + xy.y;
buildUrl += '&srs=EPSG:28992';
this.url = buildUrl;
},
sync: function (method, model, options) {
options.dataType = "jsonp";
options.crossDomain = true;
options.jsonpCallback = "parseResponse";
options.contentType = "application/json; charset=utf-8";
return Backbone.sync(method, model, options);
}
});
这是我从服务器获得的响应:
parseResponse({"type":"FeatureCollection","totalFeatures":1,"features":[{"type":"Feature","id":"MEGO_overstromingNL_Status.1754","geometry":null,"properties":{"CODE":3}}]})
任何帮助将不胜感激
答案 0 :(得分:0)
在question on gis.stackexchange.com中回答了这个问题。
存在许多可能的问题:
web.xml
文件中启用Jsonp。text/javascript
输出格式。