0

Please take a look at these codes:

$.ajax( {
      url: 'https://example.com/wp-json/wp/v2/mp3?per_page=1&_embed',
      success: function ( data ) {
        var post = data[0];
        $postid =  post.id;
.
.
.
    $.ajax( {
      url: 'https://example.com/wp-json/wp/v2/comments?post=' + $postid,

When I open the page, in the console I see this line:

https://example.com/wp-json/wp/v2/comments?post=undefined

Please tell me why it says $postid is undefined and how can I add the value of the $postid at the end of the second url.

Sadegh
  • 327
  • 2
  • 20

0 Answers0