当我使用下面的代码发出请求时,我的C#方法未获得任何数据:
$http({
method : 'POST',
url : ...,
data : {
test : 'hello'
})
.then(function (result) {
console.log('success')
}, function () {
console.log('error')
})
在调试模式下,我可以执行该方法,但是没有数据与请求一起传递。
这是一个常见的错误。您的通话应如下所示:
$http({ method: 'POST',
url: ...,
data: $httpParamSerializerJQLike({ test: 'hello' }),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
)
.then(function () { console.log('success') },
function () { console.log('error') })
也不要忘记注入$ httpParamSerializerJQLike
有关更多详细说明-> AngularJs $ http.post()不发送数据
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句