title: getting [Object Object] in place of String in Javascript visualforce page
body: <p>Here is my controller class:</p>
  
  <pre><code>global class MyJSController {
      public static String objj { get; set; }
  
      @RemoteAction
      public static String getObject_name(){
          return objj;
      }
      @RemoteAction
      public static void setObject_name(String s){
          objj=s;
      }
  
      public String accountName { get; set; }
  
      public static Account account { get; set; }
  
      public static List&lt;Order__c&gt; order{get;set;}
  
      public static List&lt;Units__C&gt;unit{get;set;}
  
      public static List&lt;Widget__c&gt; widget{get;set;}
  
      public MyJSController() { 
           setObject_name('Order');
      } // empty constructor
  
  
      @RemoteAction
      global static Account getAccount(String accountName) {
          account = [SELECT id, name, phone, type, numberofemployees
                     FROM Account WHERE name = :accountName];
          return account;
      }
  
  
      @RemoteAction
      global static Order__c[] getOrder(){
          return ([SELECT id,Name,Date__c,Inbound_Orders__c,Outbound_Orders__c from Order__c]);
      }
  
      @RemoteAction
      global static List&lt;Units__c&gt; getUnits(){
          unit=[SELECT id,Name,Date__c,Inbound_Units__c,Outbound_Units__c from Units__c];
          return unit;
      }
  
      @RemoteAction
      global static List&lt;Widget__c&gt; getWidget(){
          widget=[SELECT id,Name,Date__c,Inbound_Widgets__c,Outbound_Widgets__c from Widget__c];
          return widget;
      }
  }
  </code></pre>
  
  <p>And here is my visualforce page:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;apex:page controller="MyJSController"&gt;
  &lt;apex:form &gt;
  &lt;apex:selectList id="chooseColor" value="{!object_name}" size="1" onchange="initCharts()" &gt;
  &lt;apex:selectOption itemValue="Order" itemLabel="Order"/&gt;
  &lt;apex:selectOption itemValue="Unit" itemLabel="Unit"/&gt;
  &lt;apex:selectOption itemValue="Widget" itemLabel="Widget"/&gt;
  &lt;/apex:selectList&gt;
  &lt;/apex:form&gt;
  &lt;script type="text/javascript" src="https://www.google.com/jsapi"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
  
  
          // Load the Visualization API and the piechart package.
          google.load('visualization', '1.0', {'packages':['corechart']});
  
          // Set a callback to run when the Google Visualization API is loaded.
          google.setOnLoadCallback(initCharts);
  
          function initCharts() {        
            // Following the usual Remoting syntax
            // [&lt;namespace&gt;.]&lt;controller&gt;.&lt;method&gt;([params...,] &lt;callbackFunction&gt;(result, event) {...}
            // namespace : abhinav
            // controller : GoogleChartsController
            // method : loadOpps
  
  
  
            MyJSController.getOrder(
                   function(result, event){ 
                       // load Column chart
                      var data = new google.visualization.DataTable();
          data.addColumn('string', 'Topping');
          data.addColumn('number', 'Slices');
  
           for(var i =0; i&lt;result.length;i++){
                          var r = result[i];
                          data.addRow([r.Name,r.Inbound_Orders__c]); 
        }
        var data1=new google.visualization.DataTable();
        data1.addColumn('string','Topping');
        data1.addColumn('number','Slices');
        for(var i=0;i&lt;result.length;i++)
        {
        var r=result[i];
        data1.addRow([r.Name,r.Inbound_Orders__c]);
  
        }
  
          // Set chart options
          var options = {'title':'How Much Pizza I Ate Last Night',
                         'width':400,
                         'height':300};
  
          // Instantiate and draw our chart, passing in some options.
          var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
          var chart1= new google.visualization.AreaChart(document.getElementById('chart_hh'));
          chart.draw(data, options);
          chart1.draw(data1,options);   }, {escape:true});
  
  
            MyJSController.getObject_name(function(event,result){
           alert('Hello'+result);
          document.getElementById('dddd').innerHTML=String.ValueOf(result);  },{escape:true});
  
  
            }
  
  
  &lt;/script&gt;
  &lt;div id="chart_div" &gt;&lt;/div&gt;
  &lt;div id="chart_hh"&gt;&lt;/div&gt;
  &lt;div id="dddd"&gt;Helloojjfs&lt;/div&gt;
  &lt;/apex:page&gt;
  </code></pre>
  
  <p>When I call <code>MyJSController.getObject_name</code> in script tag (4th last line in script tag) in result I am getting <code>[Object Object]</code>. But I need <code>String Order</code> which I initialize in the constructor. Can you please tell me where I am wrong and to rectify this mistake?</p>