AngularJS $http params -


i using following function in angularjs app, facing problem in api call returns following error:

syntaxerror: unexpected token { @ object.parse (native) @ fromjson (http://localhost/app/lib/angular/angular.js:1036:14) @ $httpprovider.defaults.defaults.transformresponse (http://localhost/app/lib/angular/angular.js:6937:18) @ http://localhost/app/lib/angular/angular.js:6912:12 @ array.foreach (native) @ foreach (http://localhost/app/lib/angular/angular.js:303:11) @ transformdata (http://localhost/app/lib/angular/angular.js:6911:3) @ transformresponse (http://localhost/app/lib/angular/angular.js:7576:17) @ wrappedcallback (http://localhost/app/lib/angular/angular.js:10930:81) @ http://localhost/app/lib/angular/angular.js:11016:26  

after researching found problem in params, not sure wrong in it...can please me telling me doing wrong here , how fix it?

 savecontact: function(contact){        var deferred = $q.defer();                var params = {               name: contact.name,               phone: contact.phone         }           $http({ method:'get',                url:'http://localhost/contacts.php?action=newcontact',                params: params              }).success(function(data,status,headers,config){                  deferred.resolve(data);              }).error(function(data,status,headers,config){                  deferred.reject(status);              });        return deferred.promise;       } 

i guess problem have query params in url ("?action=newcontact"). angular trying add params contact.name , contact.phone additional query params question mark.

i try this:

  var params = {               action: 'newcontact',               name: contact.name,               phone: contact.phone         } 

and change url

http://localhost/contacts.php 

alternatively, possible supposed post new contact?


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -