title: How can I send an array from Controller to JavaScript in Laravel?
body: <p>There is data that needs to be sent to View from Controller. From what I've read, this is the way to do it,  but the alert doesn't show anything in the page. 
  Here's the method I use in Controller:</p>
  
  <pre><code>public function provider() {
      $sites = array(
      0 =&gt; "Mon", 
      1 =&gt; "Tue", 
      2 =&gt; "Wed", 
      3 =&gt; "Thu",
      4 =&gt; "Fri", 
      5 =&gt; "Sat",
      6 =&gt; "Sun",);
      return ($sites);
  }
  </code></pre>
  
  <p>And here is the javascript piece I use in View:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function provider() {
          $.ajax({
              type: "POST",
              url: '/resultsprovirder',
              cache: false,
              success: function() {
                  alert(data);
                  alert("success");
              },
              error: function() {
                  alert(data);
                  alert("error");
              }
          });
       };
  &lt;/script&gt;
  </code></pre>
  
  <p>Also, is there a more secure way than AJAX?</p>