我正在开发一个Web应用程序,并正在使用jQuery为用户提供一个良好的用户界面。因此,我使用ajax请求和许多jQuery函数。如果JavaScript在浏览器中被禁用,请求Ajax请求是否有效?
如果我在浏览器中禁用JavaScript,大部分函数将无法工作,因为我正在为许多函数发送异步ajax请求。但我该如何处理?我是否需要重写代码而不使用jQuery和ajax?
查找下面的样本按钮单击事件:
$("#renameCategory").live('click', function (event) {
if ($.trim($("#CategoryNewName").val()) == "") {
alert("Please enter a category name");
return;
}
var selectedCategory = $("#SelectedCategoryId").val();
var newCategoryName = $("#CategoryNewName").val();
var postData = { categoryId: selectedCategory, name: newCategoryName };
$.ajax({
type: "POST",
url: '@Url.Action("UpdateCategoryName", "Category")',
data: postData,
dataType: "json",
success: function (data) {
$('#' + selectedCategory).text(newCategoryName);
$("#selectedCategoryText").html(newCategoryName);
},
error: function() { alert('error') }
});
});
我该如何处理呢?