Ajax call is not responding in the first call?

$.getJSON("https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=53f08a8a7ab3407cb54b07ca5490730a", function (data) {
    var response = data.articles;
  });

First time I am not getting the data from the ajax call but from the next time on words I am getting the response.
How to get the data in the first call itself?

How do you know that? from the given code there is no indication it would not work.

since It is a web API, I am using it like that and it is working for me. I am able to get the JSON data then I am handling that data in my end but the problem is I am getting the data second time means when I trigger the data for the first time it is not working but if I trigger it for the second time it is not working but I don’t know why it is happening like that?

Or else I am ready to use any other way around to do that because I want it to be worked. that’s it

Didn’t you just say it worked?

It is working for the second time but not the first time.
I am getting all the data second time and able to show it for the user that is why I made it hit two times but in some cases, we can’t do that that is why I am asking.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.