Search Posts

Category: http

angular.js:14525 Error: [$http:baddata]

I had a error angular.js:14525 Error: [$http:baddata] Any one Can Help?? if (isset($_GET[‘do’])) { $do = $_GET[‘do’]; print_r($do); switch ($do) { case ‘check’: $this – > check(); break; case ‘getusers’: $data = getusers(); echo $data; break; } } function getusers() { global $con; $query = “SELECT * FROM follow WHERE followby=1”; $result = mysqli_query($con, $query); $rows = array(); while ($r = mysqli_fetch_assoc($result)) { $rows[] = $r; } print_r($rows); return json_encode($rows); //return json_encode($rows); //I tried here […]

How use $http for loaded page and post data in angularjs

I have a selectbox and in that selectbox whenever the user selects one destination I load a new page inside span with the class name “airlinename” When my function runs I load that page, but it shows the innerhtml instead of showing angularjs that I loaded in that page. How can I loaded page and post data? Here is my first page code: <body ng-app=”myApp” ng-controller=”myCtrl” ng-init=’rcity=[{ “name” : “Moscow”, “id” : 1182348.0 }, { […]

Getting Method Not Allowed when using AngularJS Delete

I’ll be glad to get your help. I’m using AngularJS version 1.6.5 and trying to use http delete method. On server side i’m using asp.net MVC5 Web API. When i’m trying to delete a record i’m getting error 405 (Method Not Allowed). This is my AngularJS code: $scope.Delete = function (CustomerNumber) { $http.defaults.headers[“delete”] = { ‘Content-Type’: ‘application/json,charset=utf-8’ }; $http({ method: “DELETE”, url: “/Api/Customer/” + CustomerNumber }).then(function successCallback(response) { $scope.Customers = response.data; $scope.addCustomer.$setPristine(); $scope.addCustomer.$setUntouched(); $scope.Customer = […]

Loading local JSON file error : Cross origin requests on chrome for AngularJS

I am currently trying to load in a JSON file which is being uploaded from a local directory via file upload input. This is how I am doing it: var path= document.getElementById(‘path’).value; path = “data/” + path.match(/[^/]*$/)[0]; $http({ method: ‘GET’, url: path }) .then(function(success) { console.log(success); }, function(error) { console.log(error); }); This works completely fine on firefox and it loads the data but I am getting this error on Chrome. Cross origin requests are only […]

Redirecting to static page when HTTP method is not found on Node backend

I have a single page app written in AngularJS and NodeJS. On the client side, there are several paths that the user can navigate to: http://jabaridash.com/#!/home http://jabaridash.com/#!/interests/travel When the user types in a path that does not exist such as http://jabaridash.com/#!/foo, AngularJS handles it by rerouting to the /notFound path, and then that page redirects the user back to the home page. This is the code: $urlRouterProvider.otherwise(‘/notFound’); This works when the path begins with #!/anyPath. […]

How can I pass my angularjs variable to Php page and retrive it

I am trying to pass a angularjs variable to a php page using http get but not able to access it in the php page. I want to pass a variable and then perform some calculations on that variable in the php page and then retrive it again in the html page. My code looks like: ## HTML $scope.postFunc = function(){ $http.post( “calculate.php”, {sal:$scope.sal} ).then(function(data){ alert($scope.sal); $http.get(“./calculate.php”).then(successCall,errorCall); }); } function successCall(response){ $scope.total = response.data; alert($scope.total); […]

AngularJS: $http fire and forget (no $apply)

My custom exception-Handler is sending a logging-event over $http whenever an exception occurs (similar to the example in the docs https://docs.angularjs.org/api/ng/service/$exceptionHandler ). angular. module(‘exceptionOverwrite’, []). factory(‘$exceptionHandler’, [‘$log’, ‘$http’, function($log, $http) { return function myExceptionHandler(exception, cause) { $http.post(‘myUrl.com/logErrors’, cause); $log.warn(exception, cause); }; }]); This works as desired… Except when it doesn’t: The Problem: Angular uses databinding to bind logic from controllers to the view. However this seems to cause infinity-loops in this constellation:. Whenever an Error […]

How to handle HTTP error in the client side?

What is the best way to handle HTTP errors (404, 503, etc.) when submitting a crucial data on the server? Possible solutions I came up with: having the data stored in the session for later submission (data is lost if session expired) have the data downloaded by the user and manually submit it again is it possible to store the data as cookie? Source: AngularJS

AngularJS callback error and is not a function

I have an error in line callback(response.data) telling that callback is not a function. Well, I am new to this and I am trying to figure out how to fix this issue but I am having a tough time. Any idea is appreciated. Thanks app.service(‘NotificationPollService’, function ($q, $http, $timeout) { var notification = {}; notification.poller = function (callback, error) { return $http.get(‘api/sample.php’).then(function (response) { if (typeof response.data === ‘object’) { callback(response.data); } else { error(response.data); […]

Add an exception do defaults headers in angularJS

Hello I want to use external API to gather all the current currency rate. My front is based on token and I am storing token in localForage which is nothing but async localStorage. //this execute after every page refresh $localForage.getItem(‘authorization’) .then(function(authData) { if(authData) { $scope.authentication.isAuth = true; $http.defaults.headers.common.Authorization = ‘Bearer ‘ + authData.token; //set authentication variable to true and add token to every request after page refresh } }, function(){ console.log(“error with getting authorization localForage […]

Next Page »