2013-02-04 51 views
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", 

,但我仍然得到同样的错误...

我能做些什么不正确?

+0

什么出格的在你的文本文件的 “普通”? – N0Alias

+0

@NoAlias它只是标准的HTML代码。 – StealthRT

回答

0

错误:500内部服务器错误意味着服务中存在一些内部异常。由于CustomError ON和customError模块返回在IIS中配置的HTML页面,您可能会获取HTML内容。 CustomError模块会将内容类型更改为文本/ HTML。

HTH, 阿米特