Problem receiving the response from a .post

57 Views Asked by At

I tried the following query.

When I see the answer through devtools I have the following:

{status: true, info: [,…], punitorios: [4786.6, 4677.4],…} status: true info: [,…] punitorios: [4786.6, 4677.4]

But I can't execute the code should be executed for true:

$.post('/buscarCuotas',{_token:_token,dni:dni},function(data){

    if(data.status === true)
    {
        .....

What can it be due to? I tried adding, 'json' at the end of the .post, but it didn't work

1

There are 1 best solutions below

0
C. Marca On

I think if you need to obtain a JSON data you need serialize the response, or in order to use a more updated code you can use fetch in where you can use

    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)