我有一个Ajax调用,如下所示。它适用于IE和Chrome,但不适用于Firefox。 即,在Firefox中,指定控制器中提到的控制器方法不起作用。已经进行了以下调查,但没有运气。
调用Ajax
function btnSaveDataPoint()
{
var dataPointName = $("#PointName").val();
var unit = $("#Unit").val();
var precision = $("#Precision").val();
$.ajax(
{
url: '../DataPointCRUD/SaveDataPointData',
data: { "dataPointName": dataPointName, "unit": unit, "precision": precision },
type: "POST",
dataType: "json",
contentType: 'application/json; charset=utf-8',
cache: false,
sync : false,
success: function (data) {
if (data.Message == "DataPoint added successfully") {
$("#loadDialog").dialog('close');
window.location.href = window.location.href;
}
$("#datapointerrormsg").html(data.Message);
},
error: function (data) {
alert(data.Message);
$("#datapointerrormsg").html(data.Message);
}
});
}
控制器方法
[HttpPost]
public ActionResult SaveDataPointData(string dataPointName, string unit, string precision)
{
try
{
if (dataPointName == string.Empty)
{
return Json(new { Message = "DataPoint Name is required" }, JsonRequestBehavior.AllowGet);
}
if (unit == string.Empty)
{
return Json(new { Message = "Unit is required" }, JsonRequestBehavior.AllowGet);
}
if (precision == string.Empty)
{
return Json(new { Message = "Precision is required" }, JsonRequestBehavior.AllowGet);
}
_dataPointAddEditObj.AddDataPoint(dataPointName, unit, precision);
return Json(new { Message = "DataPoint added successfully" }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
return Json(new { Message = ex.Message }, JsonRequestBehavior.AllowGet);
}
}
任何人都可以帮忙解决这个问题。