Search Posts

Category: ajax

AJAX issue with Apache .htaccess file

how to AJAX issue with Apache .htaccess file I have removed the hashbang from the URL with the below code. But for an AJAX it is loading the index.html. How can I fix? I have added <base href=”/”> in index.html and $locationProvider.html5Mode(true); in AngularJS controller. Here’s my .htaccess file RewriteEngine On # If an existing asset or directory is requested go to it as it is RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d RewriteRule ^ […]

AngularJS – .Get requests caching API output

how to AngularJS – .Get requests caching API output I have a strange problem. I am working on a frontend for an application in AngularJS, there was a bug on the API which we patched. However, my AngularJS call is still getting the old data that the API output before the fix. If I browse to that API endpoint in chrome I get the correct output, however, when looking at the network tab in developer […]

Checking if your pdf download is complete and then opening it directly using javascript

I’m developing a cross platform app using cordova. I use intel XDK as a simulator. I want to download a pdf file from webservice and open it once it gets downloaded. I have used the following code var xhr = new XMLHttpRequest();“GET”, mapusaurl); xhr.setRequestHeader(‘Authorization’,auth); xhr.responseType = “arraybuffer”; xhr.onload = function () { if (this.status === 200) { var blob = new Blob([xhr.response], {type: “application/pdf”}); var objectUrl = URL.createObjectURL(blob); var link=document.createElement(‘a’); link.href=window.URL.createObjectURL(blob);”mapusa” + new […]

Pop window does not closes after calling hide also in Angular JS

This is my function (function(){ ‘use strict’; function TablePopUpController($http, prod, tableName, $mdDialog, $scope,$timeout,$location) { $scope.tableName=tableName; var datas=[]; //$location.reload(); $scope.submitData = function() { if (tableName == ‘WFSmartPriority’) { var url = prod.TrfUrl + “/GetWFSmartPriority?tableName=” + tableName + “&OrgID=” + $scope.OrgID+”&”+prod.TrfApiKey+”&callback=JSON_CALLBACK”; $http.jsonp(url).success(function(data) { datas=data.GetWFSmartPriorityResult; // console.log(datas); hideData(datas);// Calling function to hide pop ip }); } else { if($ $’ ‘; if($scope.OrgID==undefined) $scope.OrgID=0; if($scope.userGroupID==undefined) $scope.userGroupID=0; var url = prod.TrfUrl + “/GetWFMarketOrgUserGroup?tableName=” + tableName + “&OrgID=” + $scope.OrgID + […]

How to display json array coming from url through ajax in angularjs

I have a json array coming from a url:, like this: in angularjs controller, i have something like this: $(‘#example-1’).DataTable({ “ajax” : ‘’, “columns”: [ {“data”: “companyId”}, {…..}, // I can’t assign “data” name to array because it is already unnamed. ] }); Traversing in html table_id example-1 <table id=”example-1″ class=”display” cellspacing=”0″ width=”100%”> <thead> <tr> <th>Company</th> <th>Legal Name</th> <th>DBA Name</th> <th>Formation</th> </tr> </thead> <tfoot> <tr> <th>Company</th> <th>Legal Name</th> <th>DBA Name</th> <th>Formation</th> </tr> </tfoot> Output: […]

How to compile js code to show the result of angularjs

I have a select box and in that selectbox whenever the user selects one destination i loaded new page inside span with classname “airlinename” when postEndid function runs I load that page, but it shows the innerhtml instead of showing angularjs that I loaded in that page. how can I define in my js code specially in postEndid function to compile my code before loading the second page that I have angular js inside it […]

how to view the data when searching without submitting | angularjs

in order to make the search process faster, my client requested to view the data when just the search box is filled without even submitting, my code works fine at submitting, what should i change with my code so i can get the desired result. this is my first project with angular js, i am very new to this technology. Many thanks in advance. HTML View: <input id=”searchInput” type=”text”/> // search box where // the […]

How to implement a unit test for Angular JS controller with ajax service?

I have tried to write unit test for below code, but I can’t able to achieve it. Service code: angular.module(‘ActivityApp’).service(‘PersonService’, [ ‘$http’, function ($http) { var person = function () { return $http({ method: ‘GET’, url: ‘/apis/person’ }); }; return { Person: person } }]); Controller code angular.module(‘ActivityApp’).controller(‘PersonController’, [ ‘$scope’, ‘PersonService’, function ($scope, PersonService) { ‘use strict’; $scope.person = PersonService.Person().then(function(res) { alert( }); $ = function () { PersonService.Person().then(function (res) { alert( }); }; }]); […]

not able to alert json data in ajax success call

I am not able to alert the first name of the user $scope.Edit=function(id){ $ “<?php echo BASE_URL;?>Registration/Edit”, {id :id} ).then(function(response){ var myJSON = JSON.stringify(; alert(myJSON); //alert(response.first_name); $ = response.first_name; name(); //alert(; }); } After This function in angular js: In json response i am getting: {“id”:”4″,”first_name”:”Rupal”,”last_name”:”Pant”} my php function which return the json value is: public function Edit(){ $data = json_decode(file_get_contents(“php://input”)); $id=$data->id; $query = “select * from tbl_user where id='”.$id.”‘”; $check = $this->db->query($query); $result = […]

Next Page »