2012-03-15 49 views
1

我想從我的jQuery移動應用程序發送電子郵件到[email protected],這是一個phonegap項目。有可能使用ajax,js和jQuery mobile? 我想用這個實現'反饋'功能。用戶應該能夠從他/她的手機發送標題(產品名稱)和正文(反饋)到[email protected]使用移動應用程序發送電子郵件

我使用drupal6我所有的服務,請告訴我如何使用JavaScript來訪問Drupal的API來發送郵件

謝謝..!

+1

你只需要一臺服務器來處理郵件 – mplungjan 2012-03-15 18:09:08

回答

1

您可以提交反饋表到服務器端腳本:

HTML -

<form data-ajax="false"> 
    ... 
</form> 

data-ajax="false"是如此jQuery Mobile的不自行處理表單提交。

JS -

$('form').bind('submit', function() { 
    $.ajax({ 
     url  : 'http://myserver.com/myscript.php', 

     //add the forms input namv/value pairs to the AJAX request 
     data : $(this).serialize(), 
     success : function (serverResponse) { /*Here you can confirm the message was sent to the user*/ }, 
     error : function (jqXHR, textStatus, errorThrown) { /*Don't forget to handler errors*/ } 
    }); 

    //stop the form from submitting normally 
    return false; 
}); 

PHP -

//create a message to send 
$message = "Title: " . $_GET['title'] . "\n" . 
      "Body: " . $_GET['body']; 

//send the message 
mail('[email protected]', 'App Feedback', $message); 

由於您使用PhoneGap的,你可以得到設備的唯一ID或版本信息,並將它添加到您的表單提交。

http://docs.phonegap.com/en/1.5.0/phonegap_device_device.md.html#Device

+0

我的應用程序正在訪問drupal6的所有服務,所以請告訴我如何在我的手機應用程序使用使用JavaScript API Drupal的郵件功能 – Harsh 2012-03-17 05:20:57

相關問題