Web サービスから返された HTML を取得できない理由を理解しようとしています。
これは、WS を呼び出す私の JavaScript です。
function getTVGuide(whatsBeingSent) {
jQuery.support.cors = true;
$.ajax({
crossDomain: true,
async : true,
type: "POST",
url: "http://192.168.9.7/Service.asmx/getTVGuideData",
data: '',
contentType: "application/json",
dataType: "json",
success: OnSuccessCallTVGuide,
error: OnErrorCallTVGuide
});
}
function OnSuccessCallTVGuide(response) {
console.log(response.d);
}
function OnErrorCallTVGuide(response) {
console.log('ERROR: ' + response.status + " " + response.statusText);
}
そしてWSはこれです:
<WebMethod()> Public Function getTVGuideData() As String
Try
Dim sr As StreamReader = New StreamReader("c:\tvlistings.html")
Dim line As String = ""
line = sr.ReadToEnd()
sr.Close()
Return "done"
Catch Ex As Exception
Return "err" 'Ex.Message
End Try
End Function
「DONE」のようなものを返すだけであれば、それはうまく機能します。
ただし、行を返そうとすると、機能しなくなります。エラーを与える:
ERROR: 500 Internal Server Error
AJAX の戻り値を次のように変更しようとしました。
contentType: "application/html",
dataType: "html",
そしてまた
contentType: "application/text",
dataType: "text",
しかし、私はまだ同じエラーが発生します...
私は何を間違っている可能性がありますか?