2011-02-17 39 views
0

我试图解决这一点,但我不能,不知道我应该怎么做... 然后我寻求帮助,我想知道如果有人可以帮我修复它,我已经难倒了,问题是当我点击发送按钮时只有“等待”文本出现,即使我没有填写任何字段,然后只有'等待'文本只...它似乎我的jQuery不读任何领域.. 为您的帮助,我将不胜感激,并表示感谢。需要帮助来检查我的jQuery,它不会工作

<div class="heading" id="short_msg"> </div> 
    <form id="send_to_"> 
     <table> 
     <tr> 
     <td width="150"><span class="required">*</span> <?php echo $entry_mail_to; ?></td> 
     <td><input type="text" name="mail_to" value="<?php echo $mail_to; ?>" /></td> 
     </tr> 
     <tr> 
     <td width="150"><span class="required">*</span> <?php echo $entry_subject; ?></td> 
     <td><input type="text" name="subject" value="<?php echo $subject; ?>" /></td> 
     </tr> 
     <a onclick="send__to();" class="button"><span><?php echo $button_email_to; ?></span></a> 

     </table> 
    </form> 

下面是jQuery的

<script type="text/javascript"><!-- 
function send__to() { 
    $.ajax({ 
     type: 'POST', 
     url: 'index.php?pe=submit_to&sid=<?php echo $sid; ?>&customer_id=<?php echo $customer_id; ?>', 
     dataType: 'json', 
     data: $("#send_to_").serialize(), 
    // data: 'mail_to=' + encodeURIComponent($('input[name=\'mail_to\']').val()) + 'subject=' + encodeURIComponent($('input[name=\'subject\']').val()), 
     beforeSend: function() { 
      $('.success, .warning').remove(); 
      $('#short_msg').after('<div class="wait"><img src="image/loading_1.gif" alt="" /> <?php echo $text_wait; ?></div>'); 
     }, 
     complete: function() { 
      $('.wait').remove(); 
     }, 
     success: function(data) { 
      if (data.error) { 
       $('#short_msg').after('<div class="warning">' + data.error + '</div>'); 
      } 

      if (data.success) { 
       $('#short_msg').after('<div class="success">' + data.success + '</div>'); 

      // $('input[name=\'"mail_to\']').val(''); 
      // $('input[name=\'subject\']').val(''); 
      } 
     } 
    }); 
    return false; 
} 
//--> </script> 
+1

您应该将意大利面复制到实际生成的脚本中,也就是说,如果您查看页面源代码,__browser__会显示您的意思。那些`<?php`可以生成代码,这是问题的实际来源。 – Trinidad 2011-02-17 00:57:54

+0

我建议使用萤火虫,他们有它的Firefox和一些其他浏览器,有净选项卡,它会告诉你什么类型的回应你从ajax回来。 – 2011-02-17 00:59:18

回答

2

什么似乎是目前最有可能的是,你的Ajax POST失败。如果你在Firefox上运行它,使用Firebug来查看发布的内容和返回的内容。美元兑甜甜圈,Ajax电话是而不是返回合法的JSON。