无法使用$ http.post发布请求

时间:2016-10-05 14:59:35

标签: angularjs

我只是想知道这是否是发布请求的正确方式:

$http.post(urlBase+'productattributecreate?'
    +"&products_id"="1"
    +"&attributes_id"=tab.attributeId
    +"&attributes_values_id"=tab.attributeValueId
    +"&regularPrice"=tab.regularPrice
    +"&salesPrice"=tab.salePrice
    +"&purchasePrice"=tab.purchasePrice
    +"&stockStatus"=tab.stockStatus
    +"&sttockQuantity"=tab.stockQuantity
    +"&minquantitySales"=tab.minQuantitySales
    +"&maxQuantitySales"=tab.maxQuantitySales
    +"&productImage"="")

1 个答案:

答案 0 :(得分:0)

我认为更正确的方法是:

$http.post('../productattributecreate', uploadData)

其中uploadData是包含所有数据的对象:

var uploadData = {
    products_id = '1',
    attributes_id = tab.attributeId,
    attributes_values_id = tab.attributeValueId,
    regularPrice = tab.regularPrice,
    salesPrice = tab.salePrice,
    purchasePrice = tab.purchasePrice,
    stockStatus = tab.stockStatus,
    sttockQuantity = tab.stockQuantity,
    minquantitySales = tab.minQuantitySales,
    maxQuantitySales = tab.maxQuantitySales,
    productImage = ''
};

另外......如果你用更多信息澄清了你的问题会更好。