【问题标题】:Success message is not showing in html page with ajax/jquery request成功消息未显示在带有 ajax/jquery 请求的 html 页面中
【发布时间】:2014-04-28 05:58:40
【问题描述】:

我有一个由 jquery 验证的反馈表,并使用 ajax 将请求发送到 Php 页面。所以在萤火虫中,我检查了它是否成功显示了 "Successful Message" 但为什么它没有显示在 hmtl 页面 <div id="#feedback_result"></div> 标记中?

Jquery 代码:

<script>
$(document).ready(function() {  
    // validate signup form on keyup and submit
    $("#feedback").validate({
    submitHandler: function(form) {
        $.ajax({
            url: form.action,
            type: form.method,
            //async: false,
            data: $(form).serialize(),
            beforeSend : function (){
              $('input[type=submit]').attr('disabled', false); 
            },
            success: function(response) {
            $('#feedback_result').html(response);           

            }            
        });
    },
        rules: {            
            yourfeedback: "required",           
        },
        messages: {         
            yourfeedback: "Required",           
        }
    });
});
</script>

HTML代码:

<div id="#feedback_result"></div>
<form id="feedback" method="post" action="<?php echo htmlspecialchars("feedback_process.php"); ?>">
<table width="400" border="0" cellspacing="5" cellpadding="0">  
  <tr>  
    <td>Your feedback</td>
  </tr>
  <tr>  
    <td><textarea class="textarea2" name="yourfeedback" placeholder="Your feedback"></textarea></td>
  </tr>
  <tr>  
    <td><input type="submit" id="submit" value="Send Feedback" name="submit" class="submit_button"/></td>    
  </tr>
</table>
</form>
</div>

注意:除了 id $("#order").validate({ 之外,我在同一页面中有另一个表单,它具有相同的 jquery/ajax 代码

【问题讨论】:

    标签: php jquery ajax


    【解决方案1】:

    尝试从您的id 值中删除#

    <div id="feedback_result"></div>
    

    【讨论】:

    • OOOOOOPPPS!我瞎了!!谢谢。
    猜你喜欢
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-27
    • 1970-01-01
    • 1970-01-01
    • 2021-12-01
    相关资源
    最近更新 更多