2011-02-17 43 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。