Search Posts

Category: ajax

When timeout and when abort occur in $http.get?

AngularJS 1.6.6 has support for differentiation between XHR completion, error, abort, timeout, I have this code snippet which make a request to a url like below: $http.get(url, {timeout: 1000}) .then(…) .catch(function(error) { console.log(error.xhrStatus) // could be abort, complete, error and timeout }); When requesting my api takes more than 1 second the promise is rejected with xhrStatus of ‘abort’, I was wondering in what situation I will get ‘timeout’ and ‘error’ status texts? Source: AngularJS

Server to server Http request: client promise hangs page

Overview My web application homepage launch some request to my company server which perform a server to server request to retrieve some data from a customer communication bus, but it’s not possible to change page or refresh it until these request are not completed (or closed by timeout). What I’ve tried Following this stackoverflow example and trying to manually reject all the pending ajax request: Everything is rejected except the server to server request which […]

Implement wrapper/global AJAX request handler?

In Angular.js Is it possible to implement a wrapper that will execute whenever a AJAX post request is made and gets a 401 HTTP response? My web app makes dozens of RESTful requests to the server. If their login session expires the server returns a HTTP 401 response. Now, that doesn’t trigger the ‘fail’ function of the post request (annoyingly). But even if it did, I don’t want to now edit dozens of RESTful requests […]

Showing dynamic content inside ngRepeat

Struggling to show dynamic content inside a ngRepeat. When it comes time to show my promise content, I’m getting an empty object {}: <div ng-controller=”DemoCtrl”> <div class=”sidebar” ng-repeat=”row in rows”> <div class=”row”> <input type=”checkbox”> <div class=”name”>{{row.name}}</div> <div class=”title”>{{map[$index]}}</div> </div> </div> </div> and the controller: function DemoCtrl($scope, $http, $q) { const rows = function() { const rows = []; for (let i = 0; i < 12; i++) { rows.push({ id: `demo-${i}`, name: `Demo ${i}` }); […]

Default option selected in Angularjs dropdown from ajax response as list of objects

I am new in angularjs. I was trying to select a default option in angular dropdown. I was trying to edit the previously selected option. During page load ajax get call and I get response as list of objects which has fields stateId and stateName. I can identify in jsp which id was selected previously by another object as “${summaryObj.currentLocationState}”. But when I am writing below code it’s not working. There is no problem to […]

Add a function to window object in an ajax loaded content and attached with $compile

I have this situation. I have an angular directive that “on click” on the element shows an ajax modal. Inside the modal I have html compiled with $compile service, and inside the html compiled I want to add a function to the window object. I tried but I get a “window.functionname is not a function” error. This is the directive: .directive(‘directiveName’, [‘$document’, ‘ezfb’, ‘$http’, ‘$compile’, function($document, ezfb, $http, $compile) { return { restrict: ‘EA’, link: […]

how to merge multiple auto search fields into one in angular

MarketedProgramService.getMarketedPrograms().then(function( programs ) { $scope.programs = []; var userPrograms = $filter(“filter”)( programs, MarketedProgramService.userHasAccessToProgram.bind( null, UserProfile ) ); //userPrograms.unshift( defaultProgram ); // Exclude FirstComp/Maverick programs angular.forEach( userPrograms, function( program ) { if( program.mbu != “FC” ) { $scope.programs.push( program ); } }); }); Source: AngularJS

Angularjs-probelm dont work $compile after get response of ajax

i created directive for making print page.this directive have template page that included button and print template(this have ngRepeat on Result object).print button was clicked fire “click” funciton in Controller of directive then ajax request send to server for get array of object that fill print tamplate. Mainpage.html <div ng-class=”{‘btn’:true,’btn-warning’:true,’disabled’:disableBtn}” data-toggle=”modal” ng-click=”getdetail=true;” data-target=”#detailModal”>order detail</div> <print-order disable-btn=”disableBtn” order=”selectedItem”></print-order> print.template.html <a ng-click=”ctrl.click()” ng-class=”{‘btn’:true,’btn-info’:true,’disabled’:ctrl.disableBtn}” > print <i class=”fa fa-print”></i> </a> <div id=”printSection”> <table style=”width: 100%;font:13px tahoma;” cellspacing=”0″ cellpadding=”0″> […]

form tag, created from directive does not submit

i encountered a strange behaviour that i can’t get my head around. I created a directive ‘tw-form’, that will post forms to my API as AJAX… when I tried handling the Exception of enctype=’multipart/file-data’ in this case, i just fill the action attribute, and don’t do much more. what i found, is that the form is not submitting at all!, Plunker with minimal reproducible example https://plnkr.co/edit/x1HF8V8VfYO9KHfEP1Sy EDIT: also on JSFiddle https://jsfiddle.net/TomerW/dbuc16m2/ note: if i copy […]

Ionic 1 https Forbidden 403

Good Day I need your Help!!! I have a problem on ionic 1 and I encountered a problem, I’m using codeigniter for my backend and when I post data it returns forbidden on my app I don’t know what to do I also added app transport security in Xcode, but yet still not working. Source: AngularJS

Next Page »