Home > other >  Unable to get Api response from jquery ajax
Unable to get Api response from jquery ajax

Time:02-10

I am working with Jquery and trying to fetch data (via api) using ajax, But i am getting "object object" as ajax response, Here is my data (showing in network/console )

{products: Array(6)}
products: Array(6)
0: {id: 6208935493827, title: '1988 Vintage Sturgis Motor Cycle Rally T-Shirt' …}
1: {id: 6828113199299, title: 'Dots Wood 6.5cm - Dark Grey'}
...

And here is my Script code,How can i do this ?

$('.ajx').click(function() {
$.ajax({
url:'https://dgs-staging.4psagency.com/api/products-for-vote',
type: 'POST',
dataType: 'json',
headers: {
 'Authorization': '6eadd9b2c4389d9b109b3b869f66aab5d8f9420a',
 'Accept': 'application/json'
},

success: function (result) {
 var received = JSON.parse(JSON.stringify(result));
  $.each(result.products,function(i,j){
    content ='<span>' j[i].title '<br />' j[i].title '<br /></span>';
    $('#myresult').append(content);
});
  console.log('value is ' received);
  
},
  });
 });
</script>

CodePudding user response:

  •  Tags:  
  • Related