How do I call AJAX with angularjs 1.6 and laravel 5.1? [closed]


I am trying to make an AJAX call from angular 1.6, my project is synchronized with laravel 5.1, I have a connection to the bd and I already check it, I just need to download the data and save it in vectors of js, each column a vector !!!

Being clearer, I am integrating laravel 5.1 with angularjs, the integration is, and the bd queries also work correctly, what I need is, when selecting two data (temperature, precipitation) or one of the two, and give it click on a button accept, download the data and create a vector with them in an angular service ... I already have vectors in that service, but they were data placed by hand.

asked by 30.01.2017 в 18:11

1 answer


An AJAX request in AngularJS is done through the $http service. Its use is quite similar to the ajax function of jQuery.

  method: 'GET',
  url: '/api/v1/products'
  .then(function ({ data }) {
    // hacer algo con el array de datos
  }, function (response) { // callback de error

This function returns a Promesa so it should be used then to access the expected value, in this case Response . The object Response has five entries, including data which is the one that contains the information sent by the server.

answered by 30.01.2017 / 18:24