1

次のようなajax呼び出しがあります

  $.ajax({
    datatype:'json',
    url: 'http://localhost:9090/openidm/policy/managed/user/'+storeUserId,
    type:'get',
    xhrFields: {
        withCredentials: true
    } ,   
    corssDomain:true,
    headers: {
        "X-Requested-With":"XMLHttpRequest" 
    }, 
    success: function (result){
        var validations = result.properties[1].policies[1];
        console.log(validations.policyFunction);
    },
    error:function (error){
        console.log (error);
    }
   });
});

上記の ajax 呼び出しは、次のように policyFunction を返します。

    function (fullObject, value, params, property) {
    var isRequired = _.find(this.failedPolicyRequirements, function (fpr) {
        return fpr.policyRequirement === "REQUIRED";
    }), isNonEmptyString = (typeof (value) === "string" && value.length), hasMinLength = isNonEmptyString ? (value.length >= params.minLength) : false;
    if ((isRequired || isNonEmptyString) && !hasMinLength) {
        return [{"policyRequirement":"MIN_LENGTH", "params":{"minLength":params.minLength}}];
    }
    return [];
}

私は自分のjavascriptファイルにその機能を実装したい. その関数にパラメーターを渡すようなものです。では、どうすれば実装できますか。

4

1 に答える 1