Note that there are some explanatory texts on larger screens.

plurals
  1. POAngularJS $http response long execution
    text
    copied!<p>I am using Angular and $http request to get data from server. It is mock data in the same server directory but it return response in 20 sec. It is way to long. The request is executed on application start up. I have tried to execute the same query using jQuery $.ajax, and it worked in 10 ms. But I am want to get rid of jQuery. Why AngularJs $http is taking so long?</p> <p>I am using Ifeanyi Isitor's <a href="http://ify.io/lazy-loading-in-angularjs/" rel="nofollow">Lazy Loading In AngularJS</a> example how to use require.js with angular. loading my first view's controller points to service where query is executed. In chrome dev tools network traking I see it takes less when 10 ms to get file. but using console.time setting it before executing query and ending it at success promise it logs about 20000 ms. Can it be because of lazy loading? but why jQuery is working fast? here is code of my service</p> <pre><code>define(['appModule'], function(app) { app.lazy.factory('daoService', ['$http', function($http) { var ... ... getChanges = function(tableName, modifiedSince, callback) { console.log('data access time starts'); console.time('data access time'); // this works in 20000 ms $http.post(tablesUrl[tableName]).success(function(data) { console.log("The server returned " + data.length + " changes); console.timeEnd('data access time'); callback(data); }).error(function(data){ console.log(data); }); /* this works in about 10 ms $.ajax({ url: tablesUrl[tableName], dataType:"json", success:function (data) { console.log("The server returned " + data.length + " changes ); console.timeEnd('data access time'); callback(data); }, error: function(model, response) { console.log(response); } });*/ }, </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload