[英]Problem receiving the response from a .post
我嘗試了以下查詢。
當我通過 devtools 看到答案時,我有以下幾點:
{status: true, info: [,…], punitorios: [4786.6, 4677.4],…} status: true info: [,…] punitorios: [4786.6, 4677.4]
但是我不能執行應該為true執行的代碼:
$.post('/buscarCuotas',{_token:_token,dni:dni},function(data){
if(data.status === true)
{
.....
這可能是因為什么? 我嘗試在 .post 的末尾添加“json”,但沒有用
我認為如果您需要獲取 JSON 數據,您需要序列化響應,或者為了使用更新的代碼,您可以在可以使用的地方使用fetch
fetch('URL',
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(dataForTheServer))
.then(response => response.json())
.then(data => {
if(data.status === true)
{
...
}
}).catch(errorHandler)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.