I have some values that I am inserting using jquery .load. I want to add those values together and display the result in a div (or span or whatever). Here is the code I am using to insert the values (numbers but just as plain text):
Above the closing body tag: I have:
$( "#result1" ).load( "mypage.php?f=15 .threadcount" );
$( "#result2" ).load( "mypage.php?f=16 .threadcount" );
$( "#result3" ).load( "mypage.php?f=25 .threadcount" );
$( "#result4" ).load( "mypage.php?f=18 .threadcount" );
And displaying those values further up the page using:
<div id="result1"></div>, <div id="result2"></div>... etc.
To add them together and show the total I've tried using this answer to "Add values together using jquery"
But this gives me "$NaN" as my total value. I'm assuming because it's loading that value at the same time as doing the sum? Or it doesn't recognise that bit of text coming in frm .load as a number?
I've also tried to alter code such as used in this answer to "Dynamically adding the sum of field in Jquery" answer, which adds values from form inputs as they're typed, but I'm not getting anywhere with that either.
Many thanks for any advice you can give.