我已經和Ajax請求的數據屬性JSON元素,我將數據傳遞給這樣的數據屬性:爲什麼我不能發送URL作爲傳遞給阿賈克斯
var myData = { "Identifier": 12312312,
"Description": "description",
"Name": "name",
"ImageUlr": "http://icons.iconarchive.com/icons/rob-sanders/hat/256/Hat-baseball-red-icon.png",
"Price": "price" };
$.support.cors = true;
$.ajax({ type: 'POST',
dataType: 'json',
url: myUrl + categoryId,
data: JSON.stringify(myData),
contentType: 'application/json',
success: function (returnedData) {},
error: function (xhr, ajaxOptions, thrownError) {},
processData: false,
async: false
});
而當它進入服務器(Web Api),ImageUrl爲空。這裏是我的服務器端:
public IHttpActionResult PostProduct ([FromBody] Product postedProduct, string categoryId)
{
this.dbManager.PushNewProductInCategory(postedProduct, categoryId);
return Ok();
}