Angularjs SyntaxError:JSON中位于6567位置的意外标记{
我使用AngularJS和web服务(asmx)编码连接到数据库。 我在Controller中编写了以下代码:Angularjs SyntaxError:JSON中位于6567位置的意外标记{,angularjs,asmx,Angularjs,Asmx,我使用AngularJS和web服务(asmx)编码连接到数据库。 我在Controller中编写了以下代码: var parameter = { "CartID": CartID, "Quantity": Quantity, "CostCode": costcode, "DebitTo": debitto, "ItemPriceID": ItemPriceid, "TotalPrice": TotalPrice, "LocationCode": location };
var parameter = { "CartID": CartID, "Quantity": Quantity, "CostCode": costcode, "DebitTo": debitto, "ItemPriceID": ItemPriceid, "TotalPrice": TotalPrice, "LocationCode": location };
alert(JSON.stringify(parameter));
$http({
method: 'post',
data: parameter,
url: 'wfrmOrderPlacement.asmx/AddItemsToCart',
}).then(function (response) {
//Some methods here.........
}
它工作得很好
但与我使用另一个http调用访问asmx中的另一个方法的方式相同,如下所示:
var parameter = { "SelectedLocationcode": location };
alert(JSON.stringify(parameter));
$http({
method: 'post',
data:parameter,
url: 'wfrmOrderPlacement.asmx/GetItemDetails',
}).then(function (response) {
$scope.items = response.data;
});
但这给出了所提到的错误:SyntaxError:Unexpected token{in JSON,位置6567
当我删除传递给web方法的参数时,它工作正常我猜您传递的参数有一些带大括号的代码{}…您能用数据替换数据:参数:“伪参数字符串”吗
我们可以检查传递的数据是否有问题Hi,请尝试删除逗号(,)之后url@M3ghana我已尝试删除逗号,但它没有用;仍然是相同的问题……您可以将该行粘贴到var参数的前面吗?var location=$scope.SelectedLocationcode;我正在调用函数$scope.getitemdetails=function(){}中的整个方法即使我传递参数var parameter={“SelectedLocationcode”:“39”};方法:'post',data:parameter,url:'wfrmOrderPlacement.asmx/GetItemDetails'等参数,提供数据的后端逻辑也可能出现错误。它给了我相同的错误