2016-06-01 9 views
9

デフォルトのパラメータを使用する再利用可能なJavaScript関数を作成しようとしています。しかし、IDEは私に何か間違っていると警告しています。PhpStorm - JavaScript関数パラメータIDEエラー

enter image description here

コードはこれです:

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

私は実際にそれと間違っているのか分からないのですか?あなたは何が起こっているのか理解してもらえますか? JavaScriptを&は、選択フィールドをクリックするために

1. Ctrlキーを押しながら+ ALT + S

検索:

+0

ES6を使用していますか? –

+0

http://stackoverflow.com/questions/894860/set-a-default-parameter-value-for-a-javascript-function –

+0

どちらが確実かわかりません。それは最新のIDEバージョンなので、私はES6を想定していますか? –

答えて

9

現在地バージョンを切り替えることができます。その後、ECMAScriptの6 Preferences->言語& Frameworks-> JavaScriptで

View image.

+0

これは、コードをエラーとしてマークするのを止めるために、IDEと何が関係していますか? – Barmar

+0

@Barmar私の悪い答えが更新された、 – ThomH

4

を選択し、ES6の新しい構文の機能を使用できるようにするために言語バージョンメニューから "ECMAScriptの6" を選択します。

+0

便利な説明、@Barbar。ありがとう! –

関連する問題