2017-07-17 52 views
-2

請求URL:http://10.24.120.110/mirrortin2/api/public/2ndlayer/search/[object%20Object],[object%20Object]/brandname/barcode/gender/producttype/productname
請求方法:POST
狀態代碼:200 OK
我有我的網絡上的這個錯誤,有人可以幫我這個

這是我的功能
要求[對象%20Object]

$scope.sid="scpid"; 
$scope.sid = [{todoText:'Clean House', done:false}]; 

$scope.todoAdd = function() { 
    var todoInput =""; 
    $scope.sid.push({todoText:$scope.todoInput, done:false}); 
    $scope.todoInput = ""; 
    console.log(todoInput); 
}; 

$scope.remove = function() { 
    var oldList = $scope.sid; 
    $scope.sid = []; 
    angular.forEach(oldList, function(x) { 
     if (!x.done) $scope.sid.push(x); 
    }); 
}; 

服務

function filter2ndSearch(sid, bname, bcode, gnder, ptype, pname, size_oz, size_ml, size_g, size_pcs){ 
    return $http({ 
     method: 'post', 
     url: rootURL + '/2ndlayer/search/' + sid + '/' + bname + '/' + bcode + '/' + gnder + '/' + ptype + '/' + pname ,   
     headers: { 
      'Content-Type': 'application/x-www-form-urlencoded' 
     } 
    }); 
} 
+2

'sid'和'bname'都是對象。您需要將它們串行化,而不是連接它們。 –

+0

200 OK表示一切都很好,正在運行,問題是什麼? –

+0

嗨@rory我應該修改哪些代碼? –

回答

0

我知道你的sid對象結構,並將它添加到URL中,bname的情況也是如此,bname的屬性是什麼?

url: rootURL + rootURL + '/2ndlayer/search/' + sid.todoInput + '/' + bname + '/' + bcode + '/' + gnder + '/' + ptype + '/' + pname , 
0

角提供服務作爲httpParamSerializerJQLike自1.4至發送後的數據「內容類型」:「應用程序/ x WWW的形式進行了urlencoded」。 你可以做這樣的 -

$http({ 
url: 'url', 
method: 'POST', 
data: $httpParamSerializerJQLike(data), // Make sure to inject the 
service in to the controller 
headers: { 
'Content-Type': 'application/x-www-form-urlencoded' // header 
} 
}).then(function(response) { /* do something here */ }); 

要知道它在細節,你可以參考這個 - URL-Encoding