Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/377.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GrailsRemoteFieldJavaScript_Javascript_Ajax_Grails - Fatal编程技术网

GrailsRemoteFieldJavaScript

GrailsRemoteFieldJavaScript,javascript,ajax,grails,Javascript,Ajax,Grails,我在向视图返回一个值时遇到问题,该值决定提交按钮是否可选择。我正在对照返回JSON的api调用检查accNbr的值。我只想知道是否找到了用户 “我的视图”中“我的表单”中的一个片段-以下是帐号输入: <g:remoteField paramName="accNbr" action="validateCustomer" update="[failure: 'error']" bean="${accNbrInstance}" required="" size='40' name="accNb

我在向视图返回一个值时遇到问题,该值决定提交按钮是否可选择。我正在对照返回JSON的api调用检查accNbr的值。我只想知道是否找到了用户

“我的视图”中“我的表单”中的一个片段-以下是帐号输入:

<g:remoteField paramName="accNbr" action="validateCustomer" update="[failure: 'error']" bean="${accNbrInstance}"  required="" size='40' name="accNbr" value="${accNbr}" data-trigger="change" data-required="true" data-regexp="[0-9]{12}" data-regexp-message="This field requires a valid Account Number of 12 digits"/>
和我的控制器功能:

def validateCustomer() {

    def accountNo = params.accNbr
    //def accountNo = "621137093178"
    def accountValid

    if(accountNo.length() == 12){
        def http = new HTTPBuilder('https://my.API.call/' + accountNo)
        http.auth.basic ('username','password')
        http.request(GET, ContentType.JSON) { req ->
            response.success = { resp, json ->
                assert resp.statusLine.statusCode == 200
                accountValid = json
                print("JSON is: " + json)
                println("Valid Account")
            }
        }
    }else {
        accountValid = "Not found"
        println("Invalid Account")
    }

    return accountValid
}

在jQuery中有一个if…else语句

在您的
中,如果您禁用了提交按钮:

$('#submit').attr("disabled", true);
$('#submit').attr("disabled", true);
else
中,禁用提交按钮:

$('#submit').attr("disabled", true);
$('#submit').attr("disabled", true);

我的视图中没有有效的Account,因此可以单击submit按钮