2012-08-11 41 views
0

在用於在我的網站上發送表單的php代碼存在問題。它適用於情況,但不適用於第二種情況。在某些情況下,php中的聯繫表格不會發送

情況下它的工作:

HTML表單位於mydomaine.com的根目錄

sendmessage.php位於相同的根目錄

形式調用JavaScript文件位於mydomaine.com/js/

在該JavaScript內我有下面的代碼,請注意「../sendmessage.php」

  $.ajax({ 
       type: 'POST', 
       url: '../sendmessage.php', 
       data: $("#contact").serialize(), 
       success: function(data) { 
        if(data == "true") { 
         $("#contact").fadeOut("fast", function(){ 
          $(this).before("<p><strong>Success! Your message has been sent, thank you.</strong></p>"); 
          setTimeout("$.fancybox.close()", 1000); 
         }); 
        } 

情況不工作:

HTML表單位於mydomaine.com/test/en/

sendmessage.php位於mydomaine.com/test/

的表單調用位於mydomaine.com/test/js/中的JavaScript文件

該JavaScript內我有下面的代碼,請注意「../sendmessage.php」

對我來說,它看起來OK,因爲js文件需要加載sendmessage.php(mydomaine.com/test/)向下一級(我也試圖remome的「../」,但仍無法正常工作)

  $.ajax({ 
       type: 'POST', 
       url: '../sendmessage.php', 
       data: $("#contact").serialize(), 
       success: function(data) { 
        if(data == "true") { 
         $("#contact").fadeOut("fast", function(){ 
          $(this).before("<p><strong>Success! Your message has been sent, thank you.</strong></p>"); 
          setTimeout("$.fancybox.close()", 1000); 
         }); 
        } 

回答

0

謝謝,實際上發現了這個問題,我上傳了更新後的javascript文件在錯誤的目錄中!

0

需要關於什麼是不工作的代碼和js/html和php的更多細節。看起來很簡單,應該可以工作,但可能還有其他對舊目錄結構中的路徑的引用,這些引用可能不會更新爲新的目錄結構。

也可以打開PHP錯誤以及尋找Apache日誌。

+0

謝謝,實際上發現了這個問題,我上傳了更新後的javascript文件在錯誤的目錄中! – Greg 2012-08-11 10:43:22