Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.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
Php jquery,将文本添加到特定标签中';s<;小型>;标签_Php_Jquery - Fatal编程技术网

Php jquery,将文本添加到特定标签中';s<;小型>;标签

Php jquery,将文本添加到特定标签中';s<;小型>;标签,php,jquery,Php,Jquery,在将文本附加到特定标签中时遇到问题 这是我的html代码 <label for="password"> Password <small>required</small> <input type="password" name="password" placeholder="Enter password" required pattern="[a-zA-Z]+"/> <small class="error">Pas

在将文本附加到特定标签中时遇到问题

这是我的html代码

<label for="password">
    Password <small>required</small>
    <input type="password" name="password" placeholder="Enter password" required pattern="[a-zA-Z]+"/>
    <small class="error">Password is required</small>
    <small class="server-error"></small>
</label>
$每个(消息错误,函数(k,v){
$(“label[for=“+k+”])。查找(“.server error”)。追加(“
”+v); });

此代码将在其各自的错误分区中显示列的错误。

如何构造
msg.errors
错误?它将返回k=作为标签名,例如“password”,并返回v=作为错误消息前面我这样做的方式$('label[for='+k+'])。append('+v+'');但是rite现在想把它放在小服务器错误类中为什么
find()
?您只需使用
$(“label[for=“+k+”]small.server error”).append(
“+v) @ FabiandePabian甚至更好的是:HMM不在我的目的,这是因为我正在使用基础Zurb响应遵守表单格式吗?不,我可以看到你正在使用Zurb…但是这不应该影响……你确定MSG错误吗?从我的Fibug,响应我看到这个返回{“状态”:0,“错误”:{密码”:“密码错误”}}但是我在前端没有看到这个消息
$.post('./login.php', $(this).serialize(), function(msg){
    //  working = false;
    //  $('#submit').val('Login');
    if(msg.status){
        window.location.href = "testt.php";
    }
    else {
        $.each(msg.errors,function(k,v){
            /// NOT SURE WHAT TO HAVE HERE TO GET THE SPECIFIC LABEL 
        });
        //$('#testForm').html("fail");
    }
}, 'json');
 $.each(msg.errors,function(k,v){
           $("label[for=" + k +"]").find(".server-error").append("<br>" + v);
        });