如何使用 JSON 将表单电子邮件发送到 REST 服务
我正在尝试:
// Send Mail
$('#btn_send').click(function() {
// Data object contact
this.name = $('#inputnome').val();
this.email = $('#inputemail').val();
this.subject = $('#inputassunto').val();
this.message = $('#textareamsg').val();
this.toJsonString = function() {
return JSON.stringify(this);
};
$.ajax({
type: "POST",
url: "http://localhost:8080/MailWS",
data: contact.toJsonString(),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data, status, jqXHR) {
alert(status.toString());
},
error: function(jqXHR, status) {
alert(status.toString());
}
});
});