PhpStorm - JavaScript function parameter IDE error

醉酒当歌 提交于 2019-12-04 03:05:22

问题


I am trying to build a reusable JavaScript function that makes use of default parameters. However, the IDE warns me I do something wrong.

The code is this:

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();
            }
        });
    });
}

I really don't know what is wrong with it? Can you, please, help me understand what's going on?


回答1:


You can switch the version here:

1. Press CTRL+ALT+S

2 Search for JavaScript & click the select field. and then select ECMAScript 6




回答2:


In Preferences->Languages & Frameworks->JavaScript, select "ECMAScript 6" from the language version menu to be able to use the new syntax features of ES6.



来源:https://stackoverflow.com/questions/37571400/phpstorm-javascript-function-parameter-ide-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!