ajax function returns [OBJECT OBJECT] [closed]

-1

Good morning guys. I have a problem.

I have created a function to get results in the Onchange of a select via ajax

The problem is that in this input 'qtde' is printing the following msg [OBJECT OBJECT]

Someone knows what's wrong with me?

follow the code = >

function setqtde(obj)
 {
   var item = obj.value;
   $.ajax({
    url:BASE_URL+"estoque/pegaqtde",
    type:'GET',
    data:{valor:item},
    dataType:'json',
    success:function(json)
    {

      document.getElementById("qtde").value = json;
    }
  });
 }
    
asked by anonymous 20.07.2018 / 16:38

2 answers

-1

Enter a console.log(json) in your return from json, because it is returned as an object, through the console it will be possible to see the attributes of the object. So, just access the property of the desired returned object as: json.propriedade

    
20.07.2018 / 16:48
-1

It was personal the property I needed to access was the amount

I put json.quantity; That worked out!

Thanks for the reply.

    
20.07.2018 / 17:03