Thanks for the very quick answers. I tried to implement your suggestions, but I fail because of the lack of knowledge of newcomers. I gave an example of the code that I am working with below.
I just need the JSON from $ .get to be checked for the word "error".
If an โerrorโ appears, I need var nipay to contain something like โNot Availableโ.
Otherwise, var nipay = maxBy ("year", data.series) .estpay
$.get("http://my_api_url", function(data) { var nipay = maxBy("year", data.series).estpay ; $("#box1").html("<p><b>NI:</b> " + nipay + " GBP/week </p>") });
Bizzy source share