1
嘿,我想弄清楚为什么我无法从我的Web服务获取任何返回的HTML。Web服务Ajax返回HTML
这是我的javascript调用出来的WS:
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 chanign返回值:
contentType: "application/html",
dataType: "html",
也
contentType: "application/text",
dataType: "text",
,但我仍然得到同样的错误...
我能做些什么不正确?
什么出格的在你的文本文件的 “普通”? – N0Alias
@NoAlias它只是标准的HTML代码。 – StealthRT