我有以下控制器操作:
public ActionResult AjaxQuantity(int productId = 0, double quantity = 0d, int periodId = 0)
{
...
}和适当的ajax请求:
function Quantity(productId, quantity, periodId) {
$.ajax({
url: "@(Url.Action("AjaxQuantity"))",
cache: false,
type: "GET",
data: { productId: productId, quantity: quantity, periodId: periodId },
error: function () {
Server503();
}
});
};此外,还有一个以逗号作为小数点分隔符的区域性。
例如,当我使用"12,34“作为quantity执行ajax请求时,在控制器内操作时得到的数量为1234 d。
如果我将ajax请求的类型更改为"POST",那么在12,34d的内部操作就会得到所需的数量。
GET请求是怎么回事?看上去就像在GET请求区域性中没有使用(逗号是简单的stript off)。
发布于 2014-05-15 18:53:33
问题是,',' 是一个保留的URI字符,所以您不能在GET参数中使用它。
POST参数作为请求体发送,因为','也可以在那里使用。
来自Uniform Resource Identifiers (URI): Generic Syntax 2.2。保留字符
Many URI include components consisting of or delimited by, certain
special characters. These characters are called "reserved", since
their usage within the URI component is limited to their reserved
purpose. If the data for a URI component would conflict with the
reserved purpose, then the conflicting data must be escaped before
forming the URI.
reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
"$" | ","https://stackoverflow.com/questions/23685671
复制相似问题