Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON.parse() silently fails
    primarykey
    data
    text
    <p>I'm working on a Windows desktop application, which contains an object of type System::Windows::Forms::WebBrowser. The application processes some performance data and displays an HTML page with various graphs (histograms, pie charts etc).</p> <p>It works as follows:</p> <ul> <li>The application generates an HTML file on a local temp path (e.g., .../local/path/myfile.html)</li> <li><p>The application's WebBrowser object navigates to the file generated:</p> <p>webBrowser1->Navigate(".../local/path/myfile.html")</p></li> <li><p>jQuery and some other plugins (e.g., jqPlot) are used to create various graphs and myfile.html is rendered within the applicaion</p></li> </ul> <p><strong>myfile.html contains a section of code:</strong></p> <pre><code>&lt;div id="frame-time-histograms"&gt; &lt;div id="frame-time-histogram-1"&gt; &lt;div id="frame-time-histogram-1-target-plot" class="histogram-target" style="height:250px; width:900px;"&gt;&lt;/div&gt; &lt;div id="frame-time-histogram-1-controller-plot" class="histogram-controller" style="height:100px; width:900px;"&gt;&lt;/div&gt; &lt;script id="frame-time-histogram-1-data" class="histogram-data" type="text/plain"&gt; [{"type" : "Type 1", "shortest" : 12, "longest" : 74}, [[0, 0], [1, 12.632], [2, 16.619], [3, 16.592], [4, 16.664], [5, 16.586]]] &lt;/script&gt; &lt;/div&gt; &lt;div id="frame-time-histogram-2"&gt; &lt;div id="frame-time-histogram-2-target-plot" class="histogram-target" style="height:250px; width:900px;"&gt;&lt;/div&gt; &lt;div id="frame-time-histogram-2-controller-plot" class="histogram-controller" style="height:100px; width:900px;"&gt;&lt;/div&gt; &lt;script id="frame-time-histogram-2-data" class="histogram-data" type="text/plain"&gt; [{"type" : "Type 2", "shortest" : 24, "longest" : 19}, [[0, 0], [1, 20.145], [2, 20.091], [3, 20.301], [4, 20.109], [5, 20.087]]] &lt;/script&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Note: Here I'm using script tags as data containers for my histograms.</p> <p><strong>My JavaScript file contains a section of code:</strong></p> <pre><code>var histograms = $('div#frame-time-histograms'); histograms.children().each(function(index) { var histogramTargetId = $(this).find('div.histogram-target').attr('id'); var histogramControllerId = $(this).find('div.histogram-controller').attr('id'); var histogramData = JSON.parse($(this).find('script.histogram-data').html()); </code></pre> <p>However JSON.parse() doesn't seem to do anything. I've added alert("hello") to before and after this line but only the first one is executed.</p> <p>If I go to the temp path and double click on myfile.html, JSON.parse() works fine. I can see all the graphs in my web browser (Chrome, FF and IE).</p> <p>Would anybody be able to tell me what I'm doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload