wcfサービスの電子メールに対する投稿要求をしています。件名と本文が属性であるオブジェクトです。 私はajax呼び出しをしようとすると、私は400の悪いリクエストエラーを取得していますこれは私のコードは以下のとおりです。 stringify関数にオブジェクトを配置する方法がわかりません。Jsonオブジェクトが投稿されたときに400(Bad Request)が返される
{
"email": {
"subject": "b",
"body": "d"
}
}
$('#Button1').click(function() {
var email = {
subject: $("#Text1").val(),
body: $("#Text1").val(),
}
$.ajax({
url:"http://localhost:29143/Restwebservice.svc/sendmail",
type: 'post',
cache: false,
contentType: "application/json; charset=utf-8",
dataType: 'json',
//data: JSON.stringify(email)
data: JSON.stringify(email),
success: function (data) {
$('#target').html(data.msg);
}
});
あなたのwcfサービスを直接呼び出すことはできますか? – Greg
実際に私はこのサービスをウェブサイトで呼び出しています – mehraj
Fiddlerなどのツールでhttp:// localhost:29143/Restwebservice.svc/sendmailを呼び出すと結果は得られますか? – Greg