The server gets hit twice.
On Friday, September 12, 2014 10:34:43 AM UTC-5, Eric Eslinger wrote: > > I had problems like that when I attached the same controller to multiple > viewports on the same page (using ui-router), so I'm not sure if that's the > thing. Where'd you put the console.log command to output that info? Have > you confirmed on the server side, or in the network tab of the debug tools > that the $http service is getting hit twice for certain? > > e > > On Fri, Sep 12, 2014 at 7:53 AM, mark goldin <[email protected] > <javascript:>> wrote: > >> In the Console it says: >> XHR finished loading: GET ...... >> XHR finished loading: GET ...... >> >> Two identical lines. >> >> On Friday, September 12, 2014 9:52:10 AM UTC-5, Eric Eslinger wrote: >>> >>> Is one of the two hits an OPTIONS request? If so, that's the CORS >>> preflight. >>> >>> e >>> >>> On Fri, Sep 12, 2014 at 7:16 AM, mark goldin <[email protected]> wrote: >>> >>>> Service: >>>> var myModule = angular.module('motoAdsApp', []); >>>> myModule.factory("AirportService", function ($http, $q) { >>>> return { >>>> getData : function(dateFrom, dateTo){ >>>> var deferred = $q.defer(); >>>> var response = $http({ >>>> method: "get", >>>> crossDomain: true, >>>> dataType:"xml", >>>> contentType: "application/xml", >>>> url: "http://localhost/SomePage?parameters >>>> }); >>>> response.success(function (data) { >>>> deferred.resolve(data); >>>> }); >>>> response.error(function (data) { >>>> alert('Error'); >>>> }); >>>> // Return the promise to the controller >>>> return deferred.promise; >>>> } >>>> } >>>> }); >>>> >>>> Controller: >>>> var motoAdsApp = angular.module("motoAdsApp"); >>>> motoAdsApp.controller('AirportControllers', function($scope, $http, >>>> AirportService) { >>>> var result = AirportService.getData('09/07/2014', >>>> '09/14/2014').then(function(data) { >>>> var json = $.xml2json(data); >>>> $scope.airports = json.testData; >>>> }); >>>> >>>> ....... >>>> >>>> The server gets hit twice when I load the page. Any idea why? >>>> >>>> Thanks >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "AngularJS" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To post to this group, send email to [email protected]. >>>> Visit this group at http://groups.google.com/group/angular. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "AngularJS" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at http://groups.google.com/group/angular. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
