0
每當我嘗試執行帶有AJAX的POST到我的web服務時,我都會收到「預檢的響應無效(重定向)」。我已經爲我的瀏覽器下載了一個CORS插件,我可以用它執行'GET'請求。使用AJAX進行POST返回「預檢的響應無效(重定向)」
$(function(){
var $name = $("#nameTxtB");
var $order = $("#orderTxtB");
var $price = $("#priceTxtB");
var $link = "http://localhost:51834/CoffeeService.svc/addorder";
$("#addButton").on('click', function(){
var $try1 = $price.val();
var $parse = parseInt($try1);
console.log($parse);
var CoffeeOrders = {
Name: $name.val(),
Order: $order.val(),
Price: $parse,
};
console.log(CoffeeOrders);
$.ajax({
contentType : "application/json; charset=utf-8",
dataType : 'json',
type: 'POST',
url: $link,
data: CoffeeOrders,
success: function(){
alert("Order was sucessfully created!");
},
error: function(){
alert("Something went wrong!");
}
});
});
});
謝謝!我設法解決它:D – kennyYice23