Sunday 15 July 2012

google chart Json response within 1 sec but still get timeout after 30 sec and no "pause on exception" -


I have tested this code in different constellations and only one of the constellations is giving me an error that I do not track Below it may be far below that you can see more Google-visual experience problems with someone else. In this one case, get Jason Response, then I receive a token error in the error message without identifying the token and "Stop on error" prevents my JS and nowhere in the external js. Then, after 30 seconds my callback is actually called but with error set timeout (error in query).

Here is the URL that you can also check without SSL

Here is my client js which works in many scenarios < Pre> & lt; Script type = "text / javascript" src = "https://www.google.com/jsapi" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Var chartOptions = {curveType: 'none', // width: 1200, height: 400, vAxis: {maxValue: 10, title: 'kWh / 4 (15 minutes)'}, Haxis: {title: 'time'}, Title: 'Live Production Log', Title Position: 'Out', TitleText Style: {fontSize: 14, Text Indent: 10}, Font Size: 12}; Google.load ("Visualization", "1", {packages: ["corechart"]}); Google.setOnLoadCallback (drawChart); Var _chart; Function drawChart () {// GChart data var query = new google.visualization.Query ('https://cio-services.eu/demoOe2/Api/Insight/GetESiteEuoChart/?viewFlag=1&eSiteKid=4b92d450-b29d- 47c0 -943b-00890f56caf2 & amp; periodMin = 7200 & keyProp = KW15 '); // set query parameter //query.setQuery (select '1, 2'); Query.send (drawTable); } Function drawTable (response) {// Error checking if (response.isError ()) {Warning ('Error query:' + response.getMessage () + '' + response.getDetailedMessage ()); Return; } // JSON string var googleDataQuery = response.getDataTable (). Change the response to ToJSON (); // Converted JSON conversion to Google data table = new google.visualization.DataTable (googleDataQuery, 0.5); // Start a specific data table sub set view and look in variable variables = new google.visualization.DataView (transformed data); _chart.draw (see chart option); } $ (Function () {_chart = new google.visualization.LineChart (document.getElementById ('chart_div'));}); & Lt; / Script & gt;

Okay, here magical magical is that it is necessary to pay attention to the DOC for.

JSON Response Format

The default response format is JSON if the request contains the "X-DataSource-Auth" header and otherwise JSONP, that the Google Charts client actually contains JSON and JSONP Supports modified version; If you are using Java or Python support libraries, they will exclude the appropriate code for you; If you are parsing responses by hand, see JSON modification below

What happens:

If you supply a target domain that is in some way from home (Separate port too) separates the domain, then Google-visualization decides to remove the "X-DataSource-Auth" header property, and thus the client expects jsonP instead of JSN. Obviously, RequestID is always zero in these cases. In any case, this means that you can not reuse the API only for CORS and non-CORS access.

Just look for the http request header to exclude. If the host: and the referrer: the property varies in any way, instead of refining the pure Jason, you return something like this:

string return val = "google.visualization.Query.setResponse ( "+ My-valid -PearJSan +") ";

Details here:

GG

No comments:

Post a Comment