本帖最後由 gamezz 於 2017-2-26 21:40 編輯
- this.test = function(method, url, data){
- $http({
- headers: {'Content-Type': 'application/x-www-form-urlencoded'}
- ,method: 'POST'
- ,url: url
- ,data: $httpParamSerializerJQLike(data)
- ,timeout: ajaxTimeOut
- ,responseType: 'json'
- }).then(function successCallback(response) {
- //return emtpy string
複製代碼- this.call = function(method, url, data){
- var deferred = $q.defer();
- $http({
- headers: {'Content-Type': 'application/x-www-form-urlencoded'}
- ,method: method
- ,url: url
- ,data: $httpParamSerializerJQLike(data)
- ,timeout: ajaxTimeOut
- ,responseType: 'json'
- }).then(function successCallback(response) {
- //become NAN
- deferred.resolve(response.data);
- }, function errorCallback(response) {
- deferred.reject(response.data);
- });
- return deferred.promise;
複製代碼 唔知點解, 經過$q.defer後,ajax json empty field會變成 nan ... ? |