내 코드JSON 아약스 호출 반환 응답 여기에 200 OK
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="<%= ResolveUrl("Scripts/jquery-1.3.2.min.js") %>"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" id="btn" value= "call web service" onclick="callwebservice()" />
</div>
</form>
</body>
</html>
<script type="text/javascript" language="javascript">
function AjaxFailed(result) {
alert('call stastus:' + result.status + ' ' + result.statusText);
alert('responsetest"'+result.responseText);
alert('errorthrown' + result.errorThrown);
}
function callwebservice() {
$.ajax(
{
type: "POST",
url: "default.aspx/LoginFromFacebook",
data: "",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response) {
alert(response);
},
error: AjaxFailed
}
);
}
</script>
code behind -----------------
[WebMethod()]
public static string LoginFromFacebook()
{
return "helloworld";
}
이 내가 내가 내가 점점 오전의 WebMethod를 호출하고 내의 default.aspx 파일에 하나 개의 웹 메소드가 매우 간단한 코드입니다 응답 코드는 200입니다. 피들을 사용하여 조사했습니다. 다음과 같이 응답이 있습니다. HTTP/1.1 200 OK 캐시 제어 : 개인 콘텐츠 유형 : text/html; charset = utf-8 서버 : Microsoft-IIS/7.5 X-AspNet- 버전 : 2.0.50727 X-Powered-By : ASP.NET 날짜 : 2011 년 8 월 15 일 월요일 09:16:21 GMT Content- 길이 : 1535
왜 이런 일이 발생하는지 모릅니다. 응답으로 전체 문자열의 문자열을 기대하고 있습니다.
jQuery를, 자바 스크립트 또는 asp.net 아약스를 사용하여 성공 아약스 요청에 대한 기본 단계를 포함하는 링크를
, 당신은 서버에서 다시 전송 응답을 살펴 있었다. 안녕하세요? 방화 광구를 사용하여 확인할 수 있습니다. – Steve
{ "text": "helloworld"} (으)로 돌아왔다면? 시도해 봤어? –
아니요. hello world가 응답하지 않습니다. 대신 default.aspx의 html을 얻고 있습니다. – sachin