2013-01-23 13 views
0

我正在用Sencha Touch 2開發我的第一個應用程序,並且我強烈地將我的代碼接在官方網站上的Getting Started tutorial上。 類似於入門教程(我沒有改變的代碼),在app.js當我提出我打電話contact.php形式:在Sencha Touch中與驗證和確認消息框聯繫表格

// Sends an AJAX request with the form data to the url specified above (contact.php). 
      // The success callback is called if we get a non-error response from the server 
      form.submit({ 
       success: function() { 
      // The callback function is run when the user taps the 'ok' button 
        Ext.Msg.alert('Mail received', 'We will reply soon', function() { 
      form.reset(); 
      }); 
     }, 
     }); 

但是我修改contact.php以輸出JSON消息只是如果條件得到滿足:

<?php 
if ($_POST[email] != NULL) { 
print '{"success": true}'; 
} 
?> 

現在,如果PHP輸出成功:JSON格式真app.js顯示一條警告消息(見上面的代碼)「郵件接收」。否則不會顯示任何消息。

但是,如果我想添加到contact.php其他可能的情況下觸發不同的消息,我將如何實現它們在app.js? 舉例來說,如果我修改contact.php的東西,如:

<?php 
      if ($_POST[email] != NULL) { 
      print '{"success": true}'; 
      } else { 
    print '{"wrongemail":true"}'; 
    } 
    ?> 

我將如何在app.js實現這使得不同的警報(例如,「您的電子郵件地址無效或爲空」)將出現?

預先感謝您

回答