I want to log a javascript-calculated result div from an anonymous little survey produced via a Wordpress plugin.
The html produced is:
<div ref="fieldname57_1" class="cff-summary-item">
<span class="summary-field-title cff-summary-title">Yearly costs</span>
<span class="summary-field-value cff-summary-value">£120</span></div>
(...)
It is rendered as
Yearly costs: £120
Monthly costs: 10
because the css has, for example:
fbuilder .cff-summary-title:after {
content: ': ';
}
I can grab and post the text and log it with nginx with a basic jquery post handler like this:
var stuff = jQuery('#fieldname66_1').text();
jQuery.post( "/formpost.txt", { name: "result", value: stuff } );
but everything comes out as Yearly costs£120Monthly costs£10
I can grab jQuery('#fieldname66_1').html()
but then I have the html to process.
I could do back-end processing - I'm a node-newbie but have it installed and I can see various npm packages which MIGHT be co-erced in processing the output.
I'm aware of jQuery's makeArray and toArray functions, but these still give me the html. I could use .next() to traverse my way through the spans and get the results into an array.
But ... am I missing a trick here?
When I say "log", it doesn't need to be "per line" log format -
I'd still to log the entire div "as rendered". I can't change the plugin code, even if I could let's treat this as a learning tool!
The entire page output is javascript, rendered in-browser.
Thank you!