Mih*_*hai 10 javascript parameters function default-parameters
我正在尝试构建一个JavaScript使用默认参数的可重用函数.然而,IDE警告我,我做错了什么.
代码是这样的:
function standardAjaxRequest(process_script_path, redirect = false) {
var loading = $(".loading");
var response_message = $(".response_message");
// runs the ajax to add the entry submitted
form.on("submit", function(event) {
event.preventDefault();
removeNoticeError();
var data = form.serialize();
$.ajax({
url: process_script_path,
type: "POST",
dataType: "json",
data: data,
cache: false,
success: function(response) {
if(response.status === false)
{
response_message.addClass("error").text(response.message).fadeIn(1);
}
else
{
response_message.addClass("notice").text(response.message).fadeIn(1);
if(redirect)
{
setTimeout(function () {
window.location.reload();
}, 1000);
}
else
{
response_content.after(response.content);
}
}
},
error: function() {
response_message.addClass("error").text("There was a problem adding your entry.").fadeIn(1);
},
beforeSend: function() {
toggleLoading();
},
complete: function() {
toggleLoading();
}
});
});
}
Run Code Online (Sandbox Code Playgroud)
我真的不知道它有什么问题吗?请你能帮我理解发生了什么吗?
| 归档时间: |
|
| 查看次数: |
1568 次 |
| 最近记录: |