查询:响应与配置的参数不匹配
Query: Response does not match configured parameter
我收到响应错误,请任何人尝试解决我的问题。我正在尝试解决这个问题,但我没有解决这个问题。请帮我。
提前致谢
$scope.init = {};
var Call = $resource('../api/Home', {}, { query: { method: 'POST', isArray: false} });
$scope.init = function () {
//alert("hi");
$scope.selected = "";
var x = $('#txtSearch').val();
var _ReqObj = new Object();
_ReqObj.id = x;
_ReqObj.Meth = "GJ";
Call.query({}, _ReqObj,
function (response) {
alert(response);
alert(_ReqObj);
if (response == '') {
// alert('no data');
window.location.replace("index.html");
}
else {
//$scope.click = response;
$scope.init = response;
}
},
function (error) {
window.location.replace("index.html");
}
);
};
错误消息说:"Expected response to contain an object but got an array"
这意味着:您的请求 (Call.query) 确实需要一个对象(您正在设置 isArray: false)。但是服务器发送一个数组。所以服务器没有发送函数期望的内容!
我想给你一些提示:
为什么要使用查询?查询通常用于从服务器获取数组,而不是单个对象。为什么要使用查询?
您真的想要单个对象还是想要对象列表?
服务器发送什么?在浏览器中打开开发控制台(Chrome 中的 ctr+alt+I),然后单击“网络”选项卡。单击请求 (../api/Home) 并检查来自服务器的响应。您应该看到服务器发送的 json 个对象或数组作为对您请求的响应。
我收到响应错误,请任何人尝试解决我的问题。我正在尝试解决这个问题,但我没有解决这个问题。请帮我。 提前致谢
$scope.init = {};
var Call = $resource('../api/Home', {}, { query: { method: 'POST', isArray: false} });
$scope.init = function () {
//alert("hi");
$scope.selected = "";
var x = $('#txtSearch').val();
var _ReqObj = new Object();
_ReqObj.id = x;
_ReqObj.Meth = "GJ";
Call.query({}, _ReqObj,
function (response) {
alert(response);
alert(_ReqObj);
if (response == '') {
// alert('no data');
window.location.replace("index.html");
}
else {
//$scope.click = response;
$scope.init = response;
}
},
function (error) {
window.location.replace("index.html");
}
);
};
错误消息说:"Expected response to contain an object but got an array"
这意味着:您的请求 (Call.query) 确实需要一个对象(您正在设置 isArray: false)。但是服务器发送一个数组。所以服务器没有发送函数期望的内容!
我想给你一些提示:
为什么要使用查询?查询通常用于从服务器获取数组,而不是单个对象。为什么要使用查询?
您真的想要单个对象还是想要对象列表?
服务器发送什么?在浏览器中打开开发控制台(Chrome 中的 ctr+alt+I),然后单击“网络”选项卡。单击请求 (../api/Home) 并检查来自服务器的响应。您应该看到服务器发送的 json 个对象或数组作为对您请求的响应。