[![enter image description here](https://i.stack.imgur.com/hQZtz.png)](https://i.stack.imgur.com/hQZtz.png)[![enter image description here](https://i.stack.imgur.com/FBSaz.png)](https://i.stack.imgur.com/FBSaz.png)my ajax result was working perfect but now its stuck on some queries.I am scraping data from youtube with youtube videoID given. But it not showing anything.
Like my url is <http://localhost:8080/search/6uymnYvAUKM> then it will show undefined result but when I search using some keywords it works perfect.Basically I am scraping result from youtube.Its a youtube video Id. And when I search for other words it works.

```
function search_Q() {
    //alert("base url");
    var query_search = '{{Query}}';
    //alert(query_search);
    var q = query_search;//$("#q").val();
    alert(q);
    if (q) {
      $.ajax({

        url: "/api/search",
        data: { q: q },
        type: "GET",
        dataType: "json",
        beforeSend: function () {
          $("#loading_img").css('display', 'inline');
          $("#result").empty();
        },
        success: function (result1) {
          var event_data = '';
          var title;

          //alert(check);
          for (var i = 0; i <= 14; i++) {
            if (typeof result1[i]['video']['id'] != 'undefined') {
              event_data += '<div class="col-xs-6 col-sm-4 col-md-3">';
              event_data += '<div class="thumbnail">';
              event_data += '<a class="item-thumbnail" style="position: relative"  target="_blank" href='+base_url+'download/' + result1[i]['video']['title_url'] + '/' + result1[i]['video']['id'] + '>';
              event_data += '<img class="ythumbnail" ' + 'src=' + result1[i]['video']['thumbnail_src'] + '> </a>';
              event_data += '<div class="search-info">';
              event_data += '<a  target="_blank" href='+base_url +'download/' +result1[i]['video']['title_url'] + '/' + result1[i]['video']['id'] + '>' + result1[i]['video']['title'] + ' </a>';
              event_data += '<p> <a class="btn btn-success btn-xs" target="_blank"  href='+base_url +'download/' + result1[i]['video']['title_url'] + '/' + result1[i]['video']['id'] + '>';
              event_data += '<i class="glyphicon glyphicon-download-alt"></i>&nbsp; Download video</a> </p> <br> </div></div></div>';
            }
          }
          $("#loading_img").css('display', 'none');
          $("#result").append(event_data);

        },
        error: function (jqxhr, status, exception) {
          alert('Sorry Try Again.', exception);
        },
        always: function (xhr, status) {
          alert("The request is complete!");
        }
      });
    }
  }

```

My Router code

```
router.get('/search/:query', function (req, res) {

  var q = req.params.query;

    res.render('index', {
      Query: q
    });

});

```

PS:I shall be very thankful if guys can help. Thanks.