logo
down
shadow

What does google.setOnLoadCallback(initialize) function exactly mean?


What does google.setOnLoadCallback(initialize) function exactly mean?

By : user3861822
Date : November 21 2020, 07:01 PM
around this issue Your initialize function will be called when your document (including the Google API) is fully loaded. So you should wrap any code that uses the API in the function you pass in:
E.g.
code :


Share : facebook icon twitter icon
Why isn't this google.load, google.setOnLoadCallback script working?

Why isn't this google.load, google.setOnLoadCallback script working?


By : Kai Niklas
Date : March 29 2020, 07:55 AM
wish helps you Why doesn't this jquery work, according to firebug none of the javascript lines are being reached: , You have a missing right parenthesis ):
code :
google.load("jquery", "1.4.0");
google.setOnLoadCallback(function() {
  $("p").css("background-color","red");
}); // <--- Here
Use parameter in function passed to google.setOnLoadCallback();

Use parameter in function passed to google.setOnLoadCallback();


By : user3048133
Date : March 29 2020, 07:55 AM
I hope this helps . The following are the steps to make it work:
Place google.load and google.setOnLoadCallback in a separate script tag. Use a function expression.
code :
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
  google.load("visualization", "1", {packages:["corechart"]});
  google.setOnLoadCallback(function() { drawChart(data1); });
</script>
<script type="text/javascript">

  var data1 = new google.visualization.DataTable();
    data1.addColumn('string', 'Year');
    data1.addColumn('number', 'Sales');
    data1.addRows(4);
    data1.setValue(0, 0, '2004');
    data1.setValue(0, 1, 1000);
    data1.setValue(1, 0, '2005');
    data1.setValue(1, 1, 1170);
    data1.setValue(2, 0, '2006');
    data1.setValue(2, 1, 660);
    data1.setValue(3, 0, '2007');
    data1.setValue(3, 1, 1000);

  function drawChart(data) {
    var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
    chart.draw(data, {width: 400, height: 240, title: 'Company Performance',
                      hAxis: {title: 'Year', titleTextStyle: {color: 'red'}}
                     });
  }
</script>
</head>

<body>
  <div id="chart_div"></div>
</body>
</html>
google.setOnLoadCallback(drawChart);

google.setOnLoadCallback(drawChart);


By : Dani Gil
Date : March 29 2020, 07:55 AM
Hope this helps I managed with it as i wanted, It can be helpful for someone, and if there is better solution for this please do suggest.
Google setOnLoadCallback and Ajax

Google setOnLoadCallback and Ajax


By : JPalo
Date : March 29 2020, 07:55 AM
seems to work fine The data is undefined with the getData() function. The code you have currently posted is incomplete. Looking at your fiddle there is a line between getData and drawChart functions: getData();
that immediately calls your getData function before the ajax call has been completed. Remove this line and it should work.
code :
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
    google.load('visualization', '1.1', {packages: ['line']});
google.load('visualization', '1.1', {packages: ['line']});
google.setOnLoadCallback(function() {
    drawChart(cols, rows);
});
drawChart(cols, rows);
google.setOnLoadCallback with parameter inside jquery ajax success function

google.setOnLoadCallback with parameter inside jquery ajax success function


By : Toddy Log
Date : March 29 2020, 07:55 AM
it should still fix some issue first, you're using the old version of google charts,
the jsapi library should no longer be used,
code :
google.load("visualization", "1", { packages: ["corechart"] });
google.charts.load("current", { packages: ["corechart"] });
google.charts.setOnLoadCallback(drawChart);
google.charts.load('current', {
  callback: drawChart,
  packages: ['corechart']
});
google.charts.load('current', {
  packages: ['corechart']
}).then(drawChart);
google.charts.load('current', {
  packages: ['corechart']
}).then(function () {

  // get data for chart 1
  $.ajax({
    type: 'POST',
    ...
  }).done(function (result) {

    drawChart1(result.d);

  }).fail(function (jqXHR, status, errorThrown) {
    console.log(errorThrown);
  });

  // get data for chart 2
  $.ajax({
    type: 'POST',
    ...
  }).done(function (result) {

    drawChart2(result.d);

  }).fail(function (jqXHR, status, errorThrown) {
    console.log(errorThrown);
  });

});

function drawChart1(chartData) {
  ...
}

function drawChart2(chartData) {
  ...
}
Related Posts Related Posts :
  • setting a value through jquery
  • When to use Javascript object literals
  • Is it possible to resize text to fit a fixed size div?
  • Javascript unset array
  • Should a "script" tag be allowed to remove itself?
  • How to use outerHTML in JavaScript?
  • How do you know if an object is JSON in javascript?
  • Javascript and backslashes replace
  • Click ID and open URL?
  • Center an Image vertically and horizontally using CSS
  • Sorting objects by property values
  • javascript number split
  • How can I upload a file?
  • how can put a javascript variable in img tag
  • Passing Variable in load
  • How do I move focus to next input with jQuery?
  • Reordering arrays
  • How can I read the value of a radio button in JavaScript?
  • what is name parameter in window.open()
  • How to add and run a javascript for only on firefox not on others?
  • reading the current url of a tab
  • How can I get selector from jQuery object
  • Javascript Browser Issue
  • Javascript compiled or not? Check inside
  • Create a Count Up Timer in Javascript/Jquery
  • In Javascript, what's better than try/catch for exiting an outer scope?
  • Using JavaScript regex to strip substring that contains parentheses
  • jquery split() and indexOf results in "Object doesn't support this property or method"
  • ActionScript to Javascript cross-compiler
  • TinyMCE and pluploader not working together
  • Writing to a new window with javascript... get access denied
  • Differences between testing JavaScript and testing Ajax?
  • What JavaScript functions are supported by different browsers?
  • passing input text value to ajax call
  • Can JavaScript load raw bytes to use in HTML5 Canvas?
  • html form.input.value is not getting printed why?
  • A good way to redirect with a POST request?
  • Detect blocked pop-up in Chrome
  • javascript location.hash refreshing in IE
  • Sproutcore: adding a custom stylesheet or script
  • Display tabs like FireFox's on my website
  • JavaScript - get detailed information about the browser
  • Javascript mouse event not captured properly when mouse moved very fast
  • Large number array compression
  • Is it possible to use a string variable to reference an element in Javascript?
  • remove params from form request
  • How to prevent direct access to my JSON service?
  • Trigger Div Click From Link
  • JavaScript multithreading in IE6?
  • Variable scoping and the jQuery.getJSON() method
  • How can I Mimic Gmail's Basic HTML option
  • jQuery.ui.draggable.js and jQuery.ui.widget.js conflict
  • Row rendering in Qooxdoo
  • Google Maps: How does Trulia create their custom InfoWIndows?
  • How can I create an automatically generated alteranate table row color?
  • this fadeIn / fadeOut jQuery code crashes my browsers- Why?
  • call a server side python script from javascript
  • Code Colorer Being Used
  • dynamically create element using javascript
  • jQuery to check if returned data object is empty
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk