Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
How do I return JSON parsed variables?

I need to return a value from json. The div#maxRecord works okay but I also need to use the variable topOfNormalRange for other conditionals. How do I do that?

<div id="maxRecord"></div>
<script>

var topOfNormalRange = getStationData('L1307')

if (topOfNormalRange > 3.0) {
do_stuff()
}
function getStationData(stRef) {

$.getJSON("https://environment.data.gov.uk/flood-monitoring/id/stations/"+stRef+"/stageScale", function(json){

// collect the data
var topOfNormalRange = json["items"]["typicalRangeHigh"];
var maxRecord = json["items"]["maxOnRecord"]["value"];

$('#maxRecord').html(maxRecord+'m');
return (topOfNormalRange);
 });
}
</script>

returns undefined

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!